很简单的程序:为什么if语句没有执行,看了一会居然没找到原因呢,很久没用C了,居然找不到错,囧
#include <stdio.h>#include<stdlib.h>
int main()
{
struct student
{
int num;
char name[20];
float score;
};
struct student student1;
struct student student2;
scanf_s("%d,%s,%f", &student1.num,student1.name,sizeof(student1.name), &student1.score);
scanf_s("%d,%s,%f", &student2.num, student2.name,sizeof(student2.name), &student2.score);
printf("The higher score is:\n");
if (student1.score > student2.score)
printf("%d %s %6.2f\n", student1.num, student1.name, student1.score);
else
{
if (student1.score < student2.score)
printf("%d %s %6.2f\n", student2.num, student2.name, student2.score);
else
{
printf("%d,%s%6.2f\n", student1.num, student1.name, student1.score);
printf("%d,%s%6.2f\n", student2.num, student2.name, student2.score);
}
}
system("pause");
}