成绩统计 - 蓝桥云课 (lanqiao.cn)
package lanqiao;
import java.util.Scanner;
public class N502 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] sc = new int[n + 1];
float num1 = 0; // 及格人数
float num2 = 0; // 优秀人数
for (int i = 1; i <= n; i++) {
sc[i] = scanner.nextInt();
}
for (int i = 1; i <= n; i++) {
if (sc[i] >= 60) {
num1++;
}
if (sc[i] >= 85) {
num2++;
}
}
float a = (1000 * num1 / n);
float b = (1000 * num2 / n);
a = fn(a);
b = fn(b);
System.out.println((int) (a / 10) + "%");
System.out.println((int) (b / 10) + "%");
}
static float fn(float num) {
if (num % 10 >= 5) {
return num + 10;
} else {
return num;
}
}
}