鱼C论坛

 找回密码
 立即注册
查看: 1029|回复: 4

[已解决]为什么前面两个数据不会进行比较呢?

[复制链接]
发表于 2022-4-11 10:21:02 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
  1. #include <stdio.h>

  2. struct
  3. {
  4.         int num;
  5.         char *name;
  6.         int C_score;
  7.         int com_score;
  8.         int PS_score;
  9.         int spor_score;
  10.         int English_score;
  11. }student;

  12. int main()
  13. {
  14.         int max = 0;
  15.         char ch[20];

  16.         printf("请输入学号:");
  17.         scanf("%d", &student.num);

  18.         printf("请输入姓名:");
  19.         scanf("%s", &student.name);

  20.         printf("请输入C语言成绩:");
  21.         scanf("%d", &student.C_score);
  22.         if(student.C_score > max)
  23.         {
  24.                 max = student.C_score;
  25.         }
  26.         printf("请输入计算机应用成绩:");
  27.         scanf("%d", &student.com_score);
  28.         if(student.com_score > max)
  29.         {
  30.                 max = student.com_score;
  31.         }
  32.         printf("请输入PS成绩:");
  33.         scanf("%d", &student.PS_score);
  34.         if(student.PS_score > max);
  35.         {
  36.                 max = student.PS_score;
  37.         }
  38.         printf("请输入体育成绩:");
  39.         scanf("%d", &student.spor_score);
  40.         if(student.spor_score > max)
  41.         {
  42.                 max = student.spor_score;
  43.         }
  44.         printf("请输入英语成绩:");
  45.         scanf("%d", &student.English_score);
  46.         if(student.English_score > max)
  47.         {
  48.                 max = student.English_score;
  49.         }

  50.         printf("score max = %d\n", max);





  51.         return 0;
  52. }
复制代码
最佳答案
2022-4-11 13:50:09
  1. if(student.PS_score > max);
复制代码

多写了分号,后面的赋值语句变成必执行的了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2022-4-11 11:32:15 | 显示全部楼层
哪两个数据?输入和输出分别是什么?
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-4-11 13:13:58 | 显示全部楼层
风车呼呼呼 发表于 2022-4-11 11:32
哪两个数据?输入和输出分别是什么?
  1. 请输入学号:12
  2. 请输入姓名:12
  3. 请输入C语言成绩:19
  4. 请输入计算机应用成绩:18
  5. 请输入PS成绩:17
  6. 请输入体育成绩:16
  7. 请输入英语成绩:15
  8. score max = 17

  9. --------------------------------
  10. Process exited after 9.791 seconds with return value 0
  11. 请按任意键继续. . .
复制代码
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2022-4-11 13:50:09 | 显示全部楼层    本楼为最佳答案   
  1. if(student.PS_score > max);
复制代码

多写了分号,后面的赋值语句变成必执行的了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2022-4-11 14:12:20 | 显示全部楼层
风车呼呼呼 发表于 2022-4-11 13:50
多写了分号,后面的赋值语句变成必执行的了

好的,谢谢,头昏眼花没看到
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-4-29 00:19

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表