zoukankan      html  css  js  c++  java
  • 1718 Rank

    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
    20070101 20070102 100 20070101 33 20070103 22 20070106 33 0 0
     
    Sample Output
    2
     1 #include <iostream>
     2 #include <algorithm>
     3 #include <stdio.h>
     4 #include <string.h>
     5 #include <math.h>
     6 using namespace std;
     7 int main()
     8 {
     9      int JK,haoma,a[1005],data,k;
    10      while(cin>>JK)
    11      {
    12          k=0;
    13          while(~scanf("%d%d",&haoma,&a[k]))
    14          {
    15              k++;
    16              if(haoma==JK)
    17              data=a[k-1];
    18              if(haoma==0&&a[k-1]==0)
    19              break;
    20          }
    21          sort(a,a+k);
    22          for(int i=0;i<k;i++)
    23          if(data<a[i])
    24          {
    25              data=k-i+1;
    26              break;
    27          }
    28          cout<<data<<endl;
    29      }
    30      return 0;
    31 }
    View Code
  • 相关阅读:
    lombok的介绍及使用
    java后端导入excel将数据写入数据库
    java后端导出excel表格
    eclipse maven打war包
    java后端树形菜单使用递归方法
    mybatis一对多查询
    @transactional作用和事务
    zookeeper安装
    Solr单机版安装
    jstat 简介(2)
  • 原文地址:https://www.cnblogs.com/wang-ya-wei/p/5277297.html
Copyright © 2011-2022 走看看