zoukankan      html  css  js  c++  java
  • 九度OnlineJudge之1018:统计同成绩学生人数

    题目描述:                       

    读入N名学生的成绩,将获得某一给定分数的学生人数输出。
    输入:                       
    测试输入包含若干测试用例,每个测试用例的格式为


    第1行:N
    第2行:N名学生的成绩,相邻两数字用一个空格间隔。
    第3行:给定分数

    当读到N=0时输入结束。其中N不超过1000,成绩分数为(包含)0到100之间的一个整数。
    输出:                       
    对每个测试用例,将获得给定分数的学生人数输出。
    样例输入:                       
    3
    80 60 90
    60
    2
    85 66
    0
    5
    60 75 90 55 75
    75
    0
    样例输出:                       
    1
    0
    2
    //很简单的一道题,但是能够很好地体现Hash方法思想的一道题
    #include <iostream>
    #include <cstring>
    
    using namespace std;
    
    int Grade[101];
    
    
    int main()
    {
        int N;
        while(cin>>N,N!=0)
        {
           memset(Grade,0,sizeof(Grade));
           while(N--)
           {
               int index ;
               cin>>index;
               ++Grade[index];                                     
           }              
          int ans;
          cin>>ans;
          cout<<Grade[ans]<<endl;                                      
        }          
      //  system("PAUSE");
        return 0;
    }
    
  • 相关阅读:
    斐波那契数列
    旋转数组的最小数字
    用两个栈实现队列
    重建二叉树
    从尾到头打印链表
    2020/01/11,人活着是为了一口气
    2020/01/11,放肆和克制,敏感层次
    2020/01/11,记忆单元
    2020/01/11,经济基础决定高层建筑和个性
    git
  • 原文地址:https://www.cnblogs.com/riskyer/p/3318044.html
Copyright © 2011-2022 走看看