PAT-乙-1038 1038 统计同成绩学生 (20 分)

在这里插入图片描述

代码

#include <stdio.h> 

int main() {
	
	int score[101] = {0};

	int n;
	scanf("%d", &n);
	
	for(int i=0; i<n; i++){
		int t;
		scanf("%d", &t);
		score[t]++;
	}
	
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		int t;
		scanf("%d", &t);
		if(i==0){
			printf("%d", score[t]);
		}
		else{
			printf(" %d", score[t]);
		}
	}
	
	return 0;
}

注解

水题。
一个萝卜一个坑,一个分数占数组一个位置。

结果

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/zhanggirlzhangboy/article/details/82947954