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

#include<stdio.h>
#include<stdlib.h>
int  main()
{struct  Student//声明结构体类型 
  {  int   num;
     char  name[20];
     float score; 
  }
  student1,student2;//定义两个结构体变量 
  scanf("%d%s%f",&student1.num,student1.name,&student1.score);//输入两个学生的数据 
  scanf("%d%s%f",&student2.num,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);
  }
  return 0;
}

2016 yang 78
2017 gang 89
The higher score is:
2017 gang 89.00

--------------------------------
Process exited after 21.43 seconds with return value 0
请按任意键继续. . .

posted @ 2017-04-08 16:10  醉疯染梦  阅读(7959)  评论(0编辑  收藏  举报