c9-2.c 839 B

1234567891011121314151617181920
  1. #include <stdio.h>
  2. int main()
  3. {struct student // 声明结构体类型struct student
  4. {int num;
  5. char name[20];
  6. float score;
  7. }student1,student2; // 定义两个结构体变量seudent1,student2
  8. scanf("%d%s%f",&student1.num,student1.name, &student1.score); //输入学生1敌数据
  9. scanf("%d%s%f",&student2.num,student2.name, &student2.score); //输入学生1敌数据
  10. printf("The higher score is:\n");
  11. if (student1.score>student2.score)
  12. printf("%d %s %6.2f\n",student1.num,student1.name, student1.score);
  13. else if (student1.score<student2.score)
  14. printf("%d %s %6.2f\n",student2.num,student2.name, student2.score);
  15. else
  16. {printf("%d %s %6.2f\n",student1.num,student1.name, student1.score);
  17. printf("%d %s %6.2f\n",student2.num,student2.name, student2.score);
  18. }
  19. return 0;
  20. }