本題要求讀入N名學生的成績,將獲得某一給定分數的學生人數輸出。
輸入格式:
輸入在第1行給出不超過105的正整數N,即學生總人數。隨后1行給出N名學生的百分制整數成績,中間以空格分隔。最后1行給出要查詢的分數個數K(不超過N的正整數),隨后是K個分數,中間以空格分隔。
輸出格式:
在一行中按查詢順序給出得分等于指定分數的學生人數,中間以空格分隔,但行末不得有多余空格。
輸入樣例:
10 60 75 90 55 75 99 82 90 75 50 3 75 90 88
輸出樣例:
3 2 0
#include<cstdio> int hashTable[110] = {0}; int main(){int n;scanf("%d",&n);int score;for(int i = 0; i < n; i++){ scanf("%d",&score);hashTable[score]++;}int m;scanf("%d",&m);for(int i = 0; i < m; i++){scanf("%d",&score);printf("%d",hashTable[score]);if(i < m - 1)printf(" ");} }
?