标签:max ++ code main span str core 成绩 结构体
水题。
#include"iostream" #include"algorithm" using namespace std; struct Student { string name,id; int score; }; int main() { int n; cin>>n; Student maxStu,minStu,temp; maxStu.score = -1; minStu.score = 101; for(int i = 0; i < n; ++i) { cin>>temp.name>>temp.id>>temp.score; if(maxStu.score < temp.score) maxStu = temp; if(minStu.score > temp.score) minStu = temp; } cout<<maxStu.name<<" "<<maxStu.id<<endl; cout<<minStu.name<<" "<<minStu.id<<endl; return 0; }
忘了结构体类型变量之间可以直接赋值。
标签:max ++ code main span str core 成绩 结构体
原文地址:https://www.cnblogs.com/keep23456/p/12312951.html