题解 | #统计同成绩学生人数#写个for循环判断一下就行
统计同成绩学生人数
https://www.nowcoder.com/practice/987123efea5f43709f31ad79a318ca69
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNext()) { int n = scanner.nextInt(); if (n == 0) break; int[] scores = new int[n]; for (int i = 0; i < n; i++) { scores[i] = scanner.nextInt(); } int target = scanner.nextInt(); int ans = 0; for (int score : scores) { if (score == target) { ans++; } } System.out.println(ans); } } }