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 ...
随机推荐
- vue-router如何参数传递
1.我们用<router-link>标签中的to属性进行传参,需要您注意的是这里的to要进行一个绑定,写成:to 先来看一下这种传参方法的基本语法: <router-link :to ...
- php 引用文件
require_once :为了避免重复加载文件. 用意:加载文件一次. require_once() 语句在脚本执行期间包括并运行指定文件.此行为和require()语句类似,唯一区别是:如果该文件 ...
- 【JZOJ6342】Tiny Counting
description analysis 首先不管\(a,b,c,d\)重复的情况方案数是正逆序对之积 如果考虑\(a,b,c,d\)有重复,只有四种情况,下面括号括起来表示该位置重复 比如\(\{a ...
- thinkphp url生成
为了配合所使用的URL模式,我们需要能够动态的根据当前的URL设置生成对应的URL地址,为此,ThinkPHP内置提供了U方法,用于URL的动态生成,可以确保项目在移植过程中不受环境的影响. 定义规则 ...
- Maven父子工程配置文件详解
项目骨架搭建成功之后. 因为父工程管理子工程.子工程相当于继承于子工程,所以子工程可以调用父工程里面的东西.那么就可以将jar包对应的配置文件书写到父工程的pom.xml文件中,注意:父工程的打包方式 ...
- <day002>Selenium基本操作+unittest测试框架
任务1:Selenium基本操作 from selenium import webdriver # 通用选择 from selenium.webdriver.common.by import By # ...
- LGP5495 Dirichlet 前缀和
题目 不是很明白为什么要叫做模板 考虑到\(a_i\)能对\(b_j\)产生贡献,当且仅当\(a_i=\prod p_k^{a_k},b_j=\prod p_k^{b_k},\forall k \ a ...
- selenium基础(窗口截图)
窗口截图 目的:当脚本执行出错时对当前窗口进行截图 方法:get_screenshot_as_file() #打开百度首页,搜索“selenium",完成后进行截图,并将结果保存至D:/te ...
- marquee标签(跑马灯效果)
- Mybatis-generator/通用Mapper/Mybatis-Plus对比
mybatis-plus-boot-starter和mybatis-spring-boot-starter冲突导致MapperScan失效问题还没有解决,只能不用mybatis-plus-boot-s ...