码迷,mamicode.com
首页 > 其他好文 > 详细

1004 成绩排名

时间:2020-02-15 18:37:35      阅读:56      评论:0      收藏:0      [点我收藏+]

标签: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;
}

 

忘了结构体类型变量之间可以直接赋值。

 

1004 成绩排名

标签:max   ++   code   main   span   str   core   成绩   结构体   

原文地址:https://www.cnblogs.com/keep23456/p/12312951.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!