当前位置: 首页 > news >正文

查找该学号学生的成绩。

从键盘输入某班学生某门课的成绩(每班人数最多不超过40人),当输入为负值时,表示输入结束,试编程从键盘任意输入一个学号,查找该学号学生的成绩。

**输入格式要求:"%ld"(学号) "%ld%d" 提示信息:"Total students are %d\n" "Input the searching ID:" "Input student’s ID and score:"

**输出格式要求:"score = %d\n" "Not found!\n"

程序的两次运行示例如下:

① Input student’s ID and score:070310122 84

Input student’s ID and score:070310123 83

Input student’s ID and score:070310124 88

Input student’s ID and score:070310125 87

Input student’s ID and score:070310126 61

Input student’s ID and score:-1 -1

Total students are 5

Input the searching ID:070310123

score = 83

② Input student’s ID and score:070310122 84

Input student’s ID and score:070310123 83

Input student’s ID and score:070310124 88

Input student’s ID and score:070310125 87

Input student’s ID and score:070310126 61

Input student’s ID and score:-1 -1

Total students are 5

Input the searching ID:070310128

Not found!

#include<stdio.h>
#define N 40
int main()
{int a[N], b[N], i, j, sum = 0, score;long int id;for (i = 0; i < N; i++){printf("Input student’s ID and score:");scanf("%ld%d", &a[i], &b[i]);if (a[i] < 0 || b[i] < 0)break;sum++;}printf("Total students are %d\n" , sum);printf("Input the searching ID:");scanf("%ld", &j);i = 0;for (i = 0; i < N; i++){if (a[i] == j && i < sum){printf("score = %d\n", b[i]);break;}else if(i >= sum){printf("Not found!\n");break;} }return 0;
}
http://www.lryc.cn/news/18856.html

相关文章:

  • 为Webpack5项目引入Buffer Polyfill
  • 【人工智能 AI 】您可以使用机器人流程自动化 (RPA) 实现自动化的 10 个业务流程:Robotic Process Automation (RPA)
  • VMware ESXi 8.0b - 领先的裸机 Hypervisor (Dell HPE Custom Image update)
  • Java:SpringBoot 整合Spring-Retry实现错误重试
  • MyBatis学习笔记(二) —— 搭建MyBatis项目
  • linux服务器上Docker中安装jenkins
  • 自考都有哪些科目?怎么搭配报考?
  • HIVE --- 高级查询
  • 【手撕源码】vue2.x双向数据绑定原理
  • Allegro如何显示层叠Options和Find操作界面
  • 【数据结构】双向链表
  • Editor工具开发基础三:自定义组件菜单拓展 CustomEditor
  • 拒绝摆烂!神仙网站Python自学,一路从入门闯到最后,边学边玩
  • Linux基础命令-locate快速查找文件
  • 揭穿数据分析的六大谎言
  • LinkSLA智能运维技术派-Redis的监控
  • Hugging face 模型微调学习:T5-base的微调
  • JavaScript 测试 Prototype
  • pnpm / yarn / npm管理依赖包
  • 注意力机制详解系列(一):注意力机制概述
  • 搜索引擎 Elasticsearch 的三大坑
  • 运营级手机直播平台源码 短视频直播带货APP源码
  • http/HTTPS相关的一些知识
  • MySQL高可用 集群(MHA)
  • 【JavaScript速成之路】JavaScript运算符
  • 计网个人作业05
  • 码匠 × OpenAI :快速生成 SQL 语句,提升开发效率!
  • 电脑显示屏不亮但是主机已开机?5种原因以及解决方案
  • 公司项目vue cli2升级到vue cli3
  • 流程图培训