HDU 1.3.6 Rank
来源:互联网 发布:青华ug8.5编程视频教程 编辑:程序博客网 时间:2024/06/03 20:42
Problem Description
Jackson wants to know his rank in the class. The professor has posted a list of student numbers and marks. Compute Jackson’s rank in class; that is, if he has the top mark(or is tied for the top mark) his rank is 1; if he has the second best mark(or is tied) his rank is 2, and so on.
Input
The input consist of several test cases. Each case begins with the student number of Jackson, an integer between 10000000 and 99999999. Following the student number are several lines, each containing a student number between 10000000 and 99999999 and a mark between 0 and 100. A line with a student number and mark of 0 terminates each test case. There are no more than 1000 students in the class, and each has a unique student number.
Output
For each test case, output a line giving Jackson’s rank in the class.
Sample Input
2007010120070102 10020070101 3320070103 2220070106 330 0
Sample Output
2
Source
2007省赛集训队练习赛(2)
Recommend
lcy
#include<stdio.h> #include"algorithm" using namespace std; struct record{ long ID; int mark; }; record stu[1000]; int main() { //freopen("f://in.txt", "r", stdin); //freopen("f://out.txt", "w", stdout); long stuID; int markTemp,jacksonIndex; long IDtemp; while (scanf("%ld",&stuID) != EOF) { memset(stu, 0, sizeof(stu)); int len = 0; while (1) { scanf("%ld %d", &IDtemp, &markTemp); if (markTemp == 0 && IDtemp==0) break; else { if (IDtemp == stuID) jacksonIndex = len; stu[len].ID = IDtemp; stu[len++].mark = markTemp; } } int rank = 1; for (int i = 0; i < len; i++) { if (stu[i].ID != stuID&&stu[i].mark > stu[jacksonIndex].mark) rank++; } printf("%d\n", rank); } return 0; }
0 0
- HDU 1.3.6 Rank
- HDU 1.3.6 Rank
- Rank HDU
- Rank HDU
- hdu 1718 Rank
- hdu 1718 Rank
- HDU 1718--Rank
- hdu 1718 Rank
- hdu-oj 1718 Rank
- hdu 1704 Rank
- hdu-1704 Rank
- HDU 1718 Rank
- hdu 1503 Rank
- hdu 1718 Rank
- HDU 1718 Rank
- HDU 1718 Rank
- HDU 1718 Rank
- Rank of Tetris HDU
- LEETCODE 160
- HDU 1.3.5 Wooden Sticks
- Hive 表加载,导出和查询
- UISwitch 的具体使用方式
- C#操作ZIP的方法
- HDU 1.3.6 Rank
- 进程的同步与互斥
- select a method for export 选项
- 摇奖机-多线程
- HDU 1.3.8 Who's in the Middle
- android日记:mediaPlayer的使用
- 常用时间函数总结
- STL中的set容器的一点总结
- 城里人的高端玩法(对股票及金融创新的本质的经典讲解)