为什么前面两个数据不会进行比较呢?
#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;
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 11:32
哪两个数据?输入和输出分别是什么?
请输入学号:12
请输入姓名:12
请输入C语言成绩:19
请输入计算机应用成绩:18
请输入PS成绩:17
请输入体育成绩:16
请输入英语成绩:15
score max = 17
--------------------------------
Process exited after 9.791 seconds with return value 0
请按任意键继续. . . if(student.PS_score > max);
多写了分号,后面的赋值语句变成必执行的了 风车呼呼呼 发表于 2022-4-11 13:50
多写了分号,后面的赋值语句变成必执行的了
好的,谢谢,头昏眼花没看到
页:
[1]