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

1001. Score

时间:2016-10-22 14:59:07      阅读:120      评论:0      收藏:0      [点我收藏+]

标签:vector   #include   algorithm   str   return   nbsp   int   operator   push   

#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

标签:vector   #include   algorithm   str   return   nbsp   int   operator   push   

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

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