鱼C论坛

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

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

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

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

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

x
#include <stdio.h>

struct
{
        int num;
        char *name;
        int C_score;
        int com_score;
        int PS_score;
        int spor_score;
        int English_score;
}student;

int main()
{
        int max = 0;
        char ch[20];

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

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

        printf("请输入C语言成绩:");
        scanf("%d", &student.C_score);
        if(student.C_score > max)
        {
                max = student.C_score;
        }
        printf("请输入计算机应用成绩:");
        scanf("%d", &student.com_score);
        if(student.com_score > max)
        {
                max = student.com_score;
        }
        printf("请输入PS成绩:");
        scanf("%d", &student.PS_score);
        if(student.PS_score > max);
        {
                max = student.PS_score;
        }
        printf("请输入体育成绩:");
        scanf("%d", &student.spor_score);
        if(student.spor_score > max)
        {
                max = student.spor_score;
        }
        printf("请输入英语成绩:");
        scanf("%d", &student.English_score);
        if(student.English_score > max)
        {
                max = student.English_score;
        }

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





        return 0;
}
最佳答案
2022-4-11 13:50:09
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
哪两个数据?输入和输出分别是什么?
请输入学号:12
请输入姓名:12
请输入C语言成绩:19
请输入计算机应用成绩:18
请输入PS成绩:17
请输入体育成绩:16
请输入英语成绩:15
score max = 17

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

使用道具 举报

发表于 2022-4-11 13:50:09 | 显示全部楼层    本楼为最佳答案   
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-10-5 18:24

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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