HDOJ--1718 Rank(水题用了点小技巧)
来源:互联网 发布:淘宝 不经过物流 收货 编辑:程序博客网 时间:2024/06/06 19:30
Problem DescriptionJackson 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.InputThe 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.OutputFor each test case, output a line giving Jackson’s rank in the class.Sample Input2007010120070102 10020070101 3320070103 2220070106 330 0Sample Output2设计思路:就是输入一个学号,(我这没有用字符串来做而是直接来一个数组了)然后在输入一堆学号和成绩,然后输出这个学号所对应的成绩排名。~~~第一次采用for死循环来输入数组数据,并且用if判断数组的有效数据附代码如下:import java.util.Scanner;public class Main {public static void main(String[] args) {Scanner sc =new Scanner(System.in);while(sc.hasNext()){long arr[]=new long[1005];long brr[]=new long[1005];long n=sc.nextLong();int conut=0;int m=0;for(int i=0;;i++){//死循环输入数据arr[i]=sc.nextLong();brr[i]=sc.nextLong();if(arr[i]==0){//学号为0则表明数组为初始值了,即前面的数据有效conut=i;//记录最大的数组下标break;//并且退出循环}if(arr[i]==n){m=i;//记录输入的学号位置}}int temp=1;//名次数,故让它所有的成绩,超过一个人加一 ,直到与所有的成绩比较完for(int i=0;i<conut;i++){if(brr[i]>brr[m]){temp++;}}System.out.println(temp);}}}
0 0
- HDOJ--1718 Rank(水题用了点小技巧)
- hdoj.1718 Rank 20141019
- HDOJ 1718 Rank
- hdoj-1718-Rank
- HDOJ 1718 Rank
- HDOJ的rank变回600+了
- HDOJ 1718 Rank(结构体)
- HDOJ(HDU) 1718 Rank(水题、、、)
- MySQL数据库小技巧(注意点)
- HELLOWORLD级事件属性监听小技巧,随便写了点测试代码
- HELLOWORLD级事件属性监听小技巧,随便写了点测试代码[转]
- HDOJ 题目5097 Page Rank(矩阵运算,模拟)
- HDOJ 题目2643 Rank(斯特林第二类数)
- iOS 小技巧及注意点(OC)
- JavaScript中的小技巧和注意点(一)
- JavaScript中的小技巧和注意点(二)
- 水题 hdoj-2006奇数偶数判断小技巧 、 hdoj-2007
- HDOJ---ACMSteps---1.3.7Rank
- 框架如何学习(一)
- ApplicationContext的初始化和BeanFactory的初始化之间的区别
- 学会如何读一个JavaWeb项目源代码
- 5.10
- python爬虫
- HDOJ--1718 Rank(水题用了点小技巧)
- js中序列化与反序列化
- git与github的基本操作
- 第四讲 李群与李代数
- (复习)Struts2配置和简单案例(一)
- TCP与 UDP区别及使用场景总结
- 调用webService学习小结
- 0.C语言序章
- 242. Valid Anagram
原创粉丝点击
热门IT博客
热门问题
老师的惩罚
人脸识别
我在镇武司摸鱼那些年
重生之率土为王
我在大康的咸鱼生活
盘龙之生命进化
天生仙种
凡人之先天五行
春回大明朝
姑娘不必设防,我是瞎子
江南旅游景点
江南小镇图片
jiangnan
我凡间来想见江南
江口
江口镇
江口县
江口是哪
图们江口
灌江口
瓯江口
大唐召唤录 江口1999
江口县门户网
江口门户网
江右
江吟
幕江吟
慕江吟
薯江吟
江哲
江团的做法
江城叶辰
江城子
江城
江城林阳
江城江暖暖
江城警事
上海江城
江城子苏轼
江城皮肤
江城皮肤科
江城暖暖
苏轼江城子
江城骨科
江暖暖江城
江城县
江城在哪里
江城在哪
江城足球网
江城是哪里
江城子密州出猎