PKU 百炼OJ 奖学金
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 奖学金的更多相关文章
- PKU 百炼OJ 简单密码
http://bailian.openjudge.cn/practice/2767/ #include<iostream> #include <cmath> #include ...
- 刘汝佳黑书 pku等oj题目
原文地址:刘汝佳黑书 pku等oj题目[转]作者:小博博Mr 一.动态规划参考资料:刘汝佳<算法艺术与信息学竞赛><算法导论> 推荐题目:http://acm.pku.edu. ...
- 百炼OJ - 1007 - DNA排序
题目链接:http://bailian.openjudge.cn/practice/1007 #include<stdio.h> #include<algorithm> usi ...
- 百炼OJ - 1005 - I Think I Need a Houseboat
题目链接:http://bailian.openjudge.cn/practice/1005/ 思路 一个半圆面积每年增长50,已知一个点坐标,求第几年点在半圆内. #include <stdi ...
- 百炼OJ - 1004 - 财务管理
题目链接:http://bailian.openjudge.cn/practice/1004/ 思路 求和取平均... #include <stdio.h> int main() { fl ...
- 百炼OJ - 1003 - Hangover
题目链接 思路 求一个数列的前n项和(1/2, 1/3, ...., 1/n)大于所给数所需的项数. #include<stdio.h> int main() { float a; whi ...
- 百炼OJ - 1002 - 方便记忆的电话号码
题目链接 思路 开个一千万的数组计数,最后遍历即可. #include<stdio.h> #include<string.h> #include<algorithm> ...
- 百炼OJ - 1001 - Exponentiation
题目链接 哇一遍AC的感觉也太爽了吧:) #include <stdio.h> #include <string.h> int times=0; char *myCalc(ch ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
随机推荐
- cookie与token对比(转)
1.cookie(储存在用户本地终端上的数据( 为了辨别用户身份.进行 session 跟踪)) HTTP协议本身是无状态的,所以需要一个标志来对用户身份进行验证 用户登录成功后,会在服务器存一个se ...
- Spring Boot环境搭建。
1.环境准备. jdk1.8 idea(如果不会激活可以看另外一篇:https://www.cnblogs.com/joeking/p/11119123.html) 2.打开idea 如果是idea的 ...
- leetcode-第10周双周赛-5081-歩进数
题目描述: 自己的提交:参考全排列 class Solution: def countSteppingNumbers(self, low: int, high: int) -> List[int ...
- 弹性网卡支持私网多IP
摘要: 弹性网卡支持多IP功能可以最多在一块弹性网卡配置20个私网IP地址,特别适用于于以下场景. 1.单个服务器上托管多个应用,提升实例利用率,每个应用对外暴露一个独立的服务IP地址. 2.当实例发 ...
- php抓取远程数据显示在下拉列表中
前言:周五10月20日的时候,经理让做一个插件,使用的thinkphp做这个demo 使用CURL抓取远程数据时如果出现乱码问题可以加入 header("content-type:text/ ...
- MyEclipse搭建Structs2开发环境
MyEclipse10搭建Strust2开发环境 - 孤傲苍狼 - 博客园https://www.cnblogs.com/xdp-gacl/p/3496242.html
- react 16更新
1.render新的返回类型 render方法支持两种新的返回类型:数组(由React元素组成)和字符串 2.错误处理 16之前,组件在运行期间如果执行出错,就会阻塞整个应用的渲染,这时候只能刷新页面 ...
- nginx css,js合并插件,淘宝nginx合并js,css插件
先下载Nginx_concat_module,下载后把它放在/usr/local/src/文件夹中,新建文件夹nginx-http-concat把下载的config ngx_http_concat_ ...
- iOS ARC下命名规则
当我在ARC模式下写以下代码的时候,编译器报错 Semantic Issue: Property's synthesized getter follows Cocoa naming conventio ...
- OBJC依赖库管理利器cocoapods 安装及使用详细图解
cocoapods: github:https://github.com/CocoaPods/CocoaPods 官方网站:http://www.cocoapods.org/ 1.安装 RubyGem ...