#include<iostream>using namespace std;struct Student{ string name; int score;};int main(){ int i,m,n; struct Student s[10]; cout<<"輸入10個學生姓名和成績:"<<endl; for(i=0; i<10; i++) cin>>s[i].name>>s[i].score; n=m=0; for(i=1; i<10; i++) { if(s[m].score>s[i].score) m=i; if(s[n].score<s[i].score) n=i; } cout<<"最高成績學生:"<<endl<<"姓名:"<<s[n].name<<" 成績:"<<s[n].score<<endl; cout<<"最低成績學生:"<<endl<<"姓名:"<<s[m].name<<" 成績:"<<s[m].score<<endl; return 0;}
#include<iostream>using namespace std;struct Student{ string name; int score;};int main(){ int i,m,n; struct Student s[10]; cout<<"輸入10個學生姓名和成績:"<<endl; for(i=0; i<10; i++) cin>>s[i].name>>s[i].score; n=m=0; for(i=1; i<10; i++) { if(s[m].score>s[i].score) m=i; if(s[n].score<s[i].score) n=i; } cout<<"最高成績學生:"<<endl<<"姓名:"<<s[n].name<<" 成績:"<<s[n].score<<endl; cout<<"最低成績學生:"<<endl<<"姓名:"<<s[m].name<<" 成績:"<<s[m].score<<endl; return 0;}