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 ...
随机推荐
- JMeter设置响应数据的编码格式
1.修改配置文件jmeter.properties第974行,默认编码格式为ISO-8859-1,手动修改为UTF-8 2.增加元器件 在线程组右键,添加->后置处理器->BeanShel ...
- redis安装配置使用
1.redis官方下载地址:https://redis.io/download 也可以github上下载,redis 64位下载地址:https://github.com/ServiceStack/r ...
- Java 基础 - 装箱, 拆箱
总结 1-装箱过程是通过调用包装器的valueOf方法实现的,而拆箱过程是通过调用包装器的 xxxValue方法实现的.(xxx代表对应的基本数据类型).例如:在装箱的时候自动调用的是Integer的 ...
- python: 函数递归与尾递归
如果一个函数在内部调用自己,那么这个函数就是递归函数. 例如一个阶乘函数:fact(n)=n! ,其实可以写成 fact(n)=n x fact(n-1). fact(n) 以递归的方式可以表示为: ...
- 廖雪峰Java16函数式编程-2Stream-7其他操作
1. 排序 Stream<T> sorted(); //按元素默认大小排序(必须实现Comparable接口) Stream<T> sorted(Comparator<? ...
- 配置文件一web.xml
前言 web.xml中标签的加载顺序:<context-param> > <listener> (spring的相关工作) > filter >servlet ...
- 异或前缀和——cf1186C
很思维的题,b的1个数和c的1个数相差为偶数时,必定有偶数个不同 反之必定有奇数个不同 #include <iostream> #include <cstdlib> #incl ...
- Objective-C 中的 Meta-class 是什么?
在这篇文章中,我关注的是 Objective-C 中的一个陌生的概念-- meta-class.在 Objective-C 中的每个类都有一个相关联的 meta-class,但是你很少会直接使用 me ...
- tp5 mkdir() 没有权限
- 解决方案 -SQL脚本建表产生ORA-00942错误
一.问题简介 1.开发环境 操作系统:win10 数 据 库:Oracle11g 数据库连接工具:Navicat Premium 2.问题简述 在使用SQL Development.Navicat ...