#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
請按任意鍵繼續. . .