输入两个学生的学号,成绩,输出成绩较高的学生的学号姓名和成绩

来源:互联网 发布:大数据麦肯锡定义 编辑:程序博客网 时间:2024/04/30 18:49
#include<stdio.h>
int main()
{
struct Student
{
long int num;
char name[20];
        float score;
} student1,student2;
scanf("%ld%s%f",&student1.num,student1.name,&student1.score);
scanf("%ld%s%f",&student2.num,student2.name,&student2.score);
printf("The higher score is:\n");
if(student1.score>student2.score)
printf("%ld  %s  %f\n",student1.num,student1.name,student1.score);
else if(student1.score<student2.score)
printf("%ld  %s  %f\n",student2.num,student2.name,student2.score);
else
{
printf("%ld  %s  %f\n",student1.num,student1.name,student1.score);
   printf("%ld  %s  %f\n",student2.num,student2.name,student2.score);
}
return 0;
}
0 0