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
  • 相关阅读:
    EBS Form菜单栏增加选项
    Oracle EBS 基础概念:弹性域-上下文字段
    EBS apps, applsys 的关系及密码更改
    设计模式-建造者模式
    微服务入门
    常见SQL编写和优化
    java 8 stream toMap问题
    mysql8.0.22在centos7.6下的简单安装
    mysql8的collate问题和修改
    springboot+security自定义登录-1-基础-自定义用户和登录界面
  • 原文地址:https://www.cnblogs.com/wang-ya-wei/p/5277297.html
Copyright © 2011-2022 走看看