首页 > 代码库 > hdu 1235 统计同成绩学生人数

hdu 1235 统计同成绩学生人数



import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] mat = new int[1001];// 最多仅仅有1000个,浪费1个
		int temp = 0, count = 0;
		while (sc.hasNext()) {
			int n = sc.nextInt();
			if (n == 0) {
				return;
			}
			for (int i = 1; i <= n; i++) {
				mat[i] = sc.nextInt();
			}
			temp = sc.nextInt();
			count = 0;
			for (int i = 1; i <= n; i++) {
				if (temp == mat[i]) {
					count++;
				}
			}
			System.out.println(count);
		}
	}

}







hdu 1235 统计同成绩学生人数