牛客网PAT练兵场-统计同成绩学生

题解:开100的数组,进行存储人数,方便查询

题目地址:https://www.nowcoder.com/questionTerminal/3df4810cc0664b8bb848d785f68f7c9b

 1 /**
 2 *
 3 *作者:Ycute
 4 *时间:2019-11-02-11.59.01
 5 *题目题意简单描述:开100的数组,进行存储人数,方便查询
 6 */
 7 
 8 
 9 #include<iostream>
10 #include<cmath>
11 #include<cstring>
12 #include<algorithm>
13 #include<vector>
14 using namespace std;
15 
16 
17 int main(){
18     int t;
19     int num[105]={0};
20     scanf("%d",&t);
21     while(t--){
22         int temp;
23         scanf("%d",&temp);
24         num[temp]++;
25     }
26     scanf("%d",&t);
27      while(t--){
28         int temp;
29         scanf("%d",&temp);
30         if(!t){
31             printf("%d\n",num[temp]);
32         }else{
33          printf("%d ",num[temp]);
34         }
35     }
36     return 0;
37 }

猜你喜欢

转载自www.cnblogs.com/cutelife/p/11781287.html