首页 > 其他 > 详细

1001. Score

时间:2016-10-22 14:56:21      阅读:275      评论:0      收藏:0      [点我收藏+]

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

class Student
{
    public:
        Student(string _name, int _score) {
            name = _name;
            score = _score;
        }
        bool operator < (const Student student)const {
            return score < student.score;
        }
        string name;
        int score;
};

int main()
{
    int n,m;
    cin>>n>>m;
    vector <Student> myStudent;


    for(int it=0; it<n; it++) {
        string name;
        int score;
        cin >> name >> score;
        Student temp(name, score);
        myStudent.push_back(temp);
    }
    sort(myStudent.begin(), myStudent.begin()+n);
    while(m--) {
        int num;
        cin>>num;
        cout<<myStudent[num-1].name<<" "<<myStudent[num-1].score<<endl;
    }
}                                

1001. Score

原文:http://www.cnblogs.com/sysu-eeman-yang/p/5987437.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!