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. FIN_WAIT_2

    来自转载:http://blog.sina.com.cn/s/blog_8e5d24890102w9yi.html 上图对排除和定位网络或系统故障时大有帮助,但是怎样牢牢地将这张图刻在脑中呢?那么你就 ...

  2. K-Anonymous Sequence

    K-Anonymous Sequence 给出一个递增的长度为n的序列\(\{a_i\}\),现在你可以进行一次操作,选择若干个数,分别减少任意一个正整数,定义权值为这些正整数之和,询问操作使得新序列 ...

  3. sublime text-----查看当前文件的编码格式

    1.preferences->settings,在user中添加 "show_encoding": true, "show_line_endings": ...

  4. 一个切图仔的 JS 笔记

    1,常用数据操作 Math.round(mum,2);num.toFixed(2);两位数 Math.floor(); 返回不大于的最大整数 Math.ceil(); 则是不小于他的最小整数 Math ...

  5. thinkphp 多层mvc

    hinkPHP基于MVC(Model-View-Controller,模型-视图-控制器)模式,并且均支持多层(multi-Layer)设计. 模型(Model)层 默认的模型层由Model类构成,但 ...

  6. (转)JS的splice()方法在for循环中的使用问题

    在写JS代码时,我们常常使用 splice 函数来删除数组中的元素,因为 splice 函数会直接对数组进行修改,从而不需再自己写一个算法来移动数组中的其他元素填补到被删除的位置.splice 功能十 ...

  7. 372 在O(1)时间复杂度删除链表节点

    原题网址:http://www.lintcode.com/zh-cn/problem/delete-node-in-the-middle-of-singly-linked-list/ 给定一个单链表中 ...

  8. HttpUrlConnection使用详解--转AAAAA

    http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/HttpConnection.html HttpUr ...

  9. Docker系列(九):Kubernetes架构深度解析

    Kubernetes重要概念 Docker解决了打包和隔离的问题,但我们需要更多:调度的问题,生命周期及健康状况,服务发现,监控,认证,容器聚合. Kubernetes概述 开源DOcker容器编排系 ...

  10. [kuangbin带你飞]专题一 简单搜索 - A - 棋盘问题

    #include<iostream> #include<cstdio> #include<string> #include<vector> #inclu ...