首页 > 代码库 > 例题9.2

例题9.2

#include<stdio.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;
}

     

 

 

10101 WANG 89
10103 LING 90
The higher score is :
10103 LING 90.00

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

例题9.2