用结构体解决问题,帮我看看哪儿错了,问题和我的代码在图片,利用结构体输出学生信息
1条回答 默认 最新
- a5156520 2022-03-06 11:39关注
把两门成绩定义为int型,然后加一个for循环遍历判断两门成绩大于90分的学生就可以了。
#include <stdio.h> typedef struct Student{ char stu_num[13]; char stu_name[21]; int stu_program_score; int stu_math_score; }; int main(void){ Student S[107]; int n,i; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%s",&S[i].stu_num); scanf("%s",&S[i].stu_name); scanf("%d",&S[i].stu_program_score); scanf("%d",&S[i].stu_math_score); } for(i=0;i<n;i++){ if(S[i].stu_program_score>90&&S[i].stu_math_score>90){ printf("%s\n",S[i].stu_num); } } return 0; }
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥15 c++头文件不能识别CDialog
- ¥15 Excel发现不可读取的内容
- ¥15 UE5#if WITH_EDITOR导致打包的功能不可用
- ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
- ¥20 yolov5自定义Prune报错,如何解决?
- ¥15 电磁场的matlab仿真
- ¥15 mars2d在vue3中的引入问题
- ¥50 h5唤醒支付宝并跳转至向小荷包转账界面
- ¥15 算法题:数的划分,用记忆化DFS做WA求调
- ¥15 chatglm-6b应用到django项目中,模型加载失败