http://bailian.openjudge.cn/ss2017/A/

#include<iostream>
#include <cmath>
#include <math.h>
#include <vector>
#include <algorithm>
struct Student
{
int num;
int chinese;
int math;
int english;
int getAllGrade()
{
return chinese + math + english;
}
};
bool compare(Student one, Student two)
{
int allGradeOne = one.getAllGrade();
int allGradeTwo = two.getAllGrade();
if (allGradeOne>allGradeTwo)
{
return true;
}
else if(allGradeOne==allGradeTwo)
{
if (one.chinese>two.chinese)
{
return true;
}
else if (one.chinese==two.chinese)
{
if (one.num<two.num)
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
}
int main()
{
int n = 0;
std::cin >> n;
std::vector<Student> students;
int cnt = 1;
for (; cnt <= n; cnt++)
{
Student tempStudent;
tempStudent.num = cnt;
int tempChinese = 0, tempMath = 0, tempEnglish = 0;
std::cin >> tempChinese >> tempMath >> tempEnglish;
tempStudent.chinese = tempChinese;
tempStudent.math = tempMath;
tempStudent.english = tempEnglish;
students.push_back(tempStudent);
}
/*for (auto tempStudent : students)
{
std::cout << tempStudent.num << ":" << tempStudent.chinese << std::endl;
}*/
sort(students.begin(), students.end(), compare);
for (int i = 0; i < 5; i++)
{
std::cout << students[i].num << " " << students[i].getAllGrade() << std::endl;
}
return 0;
}

  

PKU 百炼OJ 奖学金的更多相关文章

  1. PKU 百炼OJ 简单密码

    http://bailian.openjudge.cn/practice/2767/ #include<iostream> #include <cmath> #include ...

  2. 刘汝佳黑书 pku等oj题目

    原文地址:刘汝佳黑书 pku等oj题目[转]作者:小博博Mr 一.动态规划参考资料:刘汝佳<算法艺术与信息学竞赛><算法导论> 推荐题目:http://acm.pku.edu. ...

  3. 百炼OJ - 1007 - DNA排序

    题目链接:http://bailian.openjudge.cn/practice/1007 #include<stdio.h> #include<algorithm> usi ...

  4. 百炼OJ - 1005 - I Think I Need a Houseboat

    题目链接:http://bailian.openjudge.cn/practice/1005/ 思路 一个半圆面积每年增长50,已知一个点坐标,求第几年点在半圆内. #include <stdi ...

  5. 百炼OJ - 1004 - 财务管理

    题目链接:http://bailian.openjudge.cn/practice/1004/ 思路 求和取平均... #include <stdio.h> int main() { fl ...

  6. 百炼OJ - 1003 - Hangover

    题目链接 思路 求一个数列的前n项和(1/2, 1/3, ...., 1/n)大于所给数所需的项数. #include<stdio.h> int main() { float a; whi ...

  7. 百炼OJ - 1002 - 方便记忆的电话号码

    题目链接 思路 开个一千万的数组计数,最后遍历即可. #include<stdio.h> #include<string.h> #include<algorithm> ...

  8. 百炼OJ - 1001 - Exponentiation

    题目链接 哇一遍AC的感觉也太爽了吧:) #include <stdio.h> #include <string.h> int times=0; char *myCalc(ch ...

  9. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

随机推荐

  1. list集合排序3

    java list按照元素对象的指定多个字段属性进行排序 转载 2016年12月27日 11:39:02 见: http://blog.csdn.net/enable1234___/article/d ...

  2. python_django_models模块

    django中models模块为各类数据库提供了统一的api,可根据不同的业务需求配置数据库. models模块开发流程: 配置数据库  详情:https://www.cnblogs.com/Vera ...

  3. arc098D Xor Sum 2

    题意:给你一个数列,问有多少对(l,r)满足A[l]+A[l+1]+...+A[r]=A[l]^A[l+1]^...^A[r]? 标程: #include<bits/stdc++.h> u ...

  4. Python自学:第四章 在for循环结束后执行一些操作

    # -*- coding: GBK -*- magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(ma ...

  5. Erlang学习记录:输入和输出

    输入和输出 输入和输出功能都被定义在io模块 输出功能非常常用,由于erlang项目没有可断点调试的IDE(或者说根本不需要),所以所有的调试操作都是由io输出 来调试的 io:get_line/1. ...

  6. Android NDK应用原理

    转:http://shihongzhi.com/ndk/ 那么首先看一下Android的系统框架: 最底层是Linux Kernel,然后上面是封装的库及Android runtime.再上面是App ...

  7. 1636: Pascal山脉

    1636: Pascal山脉 时间限制: 1 Sec  内存限制: 128 MB提交: 51  解决: 15[提交][状态][讨论版] 题目描述 小卡卡顺着老者所指的方向,来到了Pascal神峰的顶峰 ...

  8. day 67 Django基础三之视图函数

    Django基础三之视图函数   本节目录 一 Django的视图函数view 二 CBV和FBV 三 使用Mixin 四 给视图加装饰器 五 Request对象 六 Response对象 一 Dja ...

  9. <jquery>基本的模态框

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. 解决asp.net web api时间datetime自动带上带上的T和毫秒的问题

    今天用asp.net web api写微信小程序的接口时遇到一个问题. 返回的model中的datetime类型的字段自动转换成了“2014-11-08T01:50:06:234”这样的字符串,带上的 ...