-
import java.io.*; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int N = Integer.parseInt(br.readLine()); for (int i = 0; i < N; i++) { StringTokenizer st = new StringTokenizer(br.readLine()); int students = Integer.parseInt(st.nextToken()); // 학생 수 double goodStudents = 0; double sum = 0; // 배열 저장 int[] points = new int[students]; for (int j = 0; j < students; j++) { points[j] = Integer.parseInt(st.nextToken()); sum += points[j]; } // avg double avg = sum / students; // goodStudents for (int point : points) { if (point > avg) { goodStudents++; } } String ans = String.format("%.3f", (goodStudents/students * 100)); bw.append(ans).append("%\n"); } bw.flush(); bw.close(); } }
- 막 깔끔하진 않은데 내가 생각했던대로 적어봤음