1001. Score

#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;
    }
}

时间: 2024-08-29 06:25:19

1001. Score的相关文章

c语言:写一个函数建立一个有3名学生数据的单向动态链表

写一个函数建立一个有3名学生数据的单向动态链表. 解:程序: #include<stdio.h> #include<stdlib.h> #define LEN sizeof(struct Student) struct Student { long num; float score; struct Student *next; }; int n; struct Student *creat(void)//定义函数返回一个指向链表头的指针 { struct Student *head

Node.js的Buffer那些你可能不知道的用法

在大多数介绍Buffer的文章中,主要是围绕数据拼接和内存分配这两方面的.比如我们使用fs模块来读取文件内容的时候,返回的就是一个Buffer: fs.readFile('filename', function (err, buf) { // <Buffer 2f 2a 2a 0a 20 2a 20 53 75 ... > }); 在使用net或http模块来接收网络数据时,data事件的参数也是一个Buffer,这时我们还需要使用Buffer.concat()来做数据拼接: var bufs

python3学习笔记--003--写一个自定义的包

代码布局: [[email protected] packagetest]$ tree . ├── mypackage │   ├── human.py │   ├── __init__.py │   └── student.py └── test.py 1 directory, 4 files [[email protected] packagetest]$ mypackage/human.py #!/usr/bin/env python class person: def __init__(

Redis在Php项目中的实际应用场景

商品维度计数 对商品喜欢数,评论数,鉴定数,浏览数进行计数说起电商,肯定离不开商品,而附带商品有各种计数(喜欢数,评论数,鉴定数,浏览数,etc)Redis的命令都是原子性的,你可以轻松地利用INCR,DECR等命令来计数. 采用Redis 的类型: Hash. 如果你对redis数据类型不太熟悉,可以参考http://redis.io/topics/data-types-intro 为product定义个key product:,为每种数值定义hashkey, 譬如喜欢数like_num $r

PAT甲级考试题库1001 A+B Format 代码实现及相关知识学习

准备参加九年九月份的PAT甲级证书考试,对网站上的题目进行总结分析: 1001题 A+B Format (20 分) Calculate a+b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits). 计算a+b的值并以一定格式输出其和sum(数字需要

paste 乙级 1001

1001. 害死人不偿命的(3n+1)猜想 (15) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 卡拉兹(Callatz)猜想: 对任何一个自然数n,如果它是偶数,那么把它砍掉一半:如果它是奇数,那么把(3n+1)砍掉一半.这样一直反复砍下去,最后一定在某一步得到n=1.卡拉兹在1950年的世界数学家大会上公布了这个猜想,传说当时耶鲁大学师生齐动员,拼命想证明这个貌似很傻很天真的命题,结果闹得学生们无心学业

设有一数据库,包括四个表:学生表(Student)、课程表(Course)、成绩表(Score)以及教师信息表(Teacher)。四个表的结构分别如表1-1的表(一)~表(四)所示,数据如表1-2的表(一)~表(四)所示。用SQL语句创建四个表并完成相关题目。

表(一)Student (学生表) -- Create table create table STUDENT ( sno VARCHAR2(3) not null, sname VARCHAR2(8) not null, ssex VARCHAR2(2) not null, sbirthday DATE, class VARCHAR2(5) ) tablespace USERS pctfree 10 initrans 1 maxtrans 255; -- Add comments to the

1001 数组中和等于K的数对

1001 数组中和等于K的数对 基准时间限制:1 秒 空间限制:131072 KB 分值: 5 难度:1级算法题 给出一个整数K和一个无序数组A,A的元素为N个互不相同的整数,找出数组A中所有和等于K的数对.例如K = 8,数组A:{-1,6,5,3,4,2,9,0,8},所有和等于8的数对包括(-1,9),(0,8),(2,6),(3,5). Input 第1行:用空格隔开的2个数,K N,N为A数组的长度.(2 <= N <= 50000,-10^9 <= K <= 10^9)

机器学习中的 precision、recall、accuracy、F1 Score

1. 四个概念定义:TP.FP.TN.FN 先看四个概念定义: - TP,True Positive - FP,False Positive - TN,True Negative - FN,False Negative 如何理解记忆这四个概念定义呢? 举个简单的二元分类问题 例子: 假设,我们要对某一封邮件做出一个判定,判定这封邮件是垃圾邮件.还是这封邮件不是垃圾邮件? 如果判定是垃圾邮件,那就是做出(Positive)的判定: 如果判定不是垃圾邮件,那就做出(Negative)的判定. Tru