-
문제 24 - 평균보다 점수가 넘은 학생들의 비율알고리즘/알고리즘 기초 100제 2020. 10. 19. 00:18
// print avg // input : 7 100 95 90 80 70 60 50 // output : 57.143% import java.util.*; /* javac Youtube24.java -encoding UTF-8 평균보다 점수가 넘은 학생들의 비율. */ class Youtube24 { public static void main(String[] args){ Scanner sc = new Scanner(System.in); System.out.println("Input the number of students"); int students = sc.nextInt(); int[] scores = new int[students]; int sum = 0; for(int i=0; i<students; i++){ scores[i] = sc.nextInt(); sum += scores[i]; } double avg = (sum/students); double count = 0; for(int score : scores){ if(avg < score){ count++; } } System.out.println((count/students)*100 + "%"); } }
이거는 그냥 수학문제 같다... 수학문제가 알고리즘인가?
'알고리즘 > 알고리즘 기초 100제' 카테고리의 다른 글
문제 25 - N의 사이클 길이 구하기 (0) 2020.10.19 문제 23번 - 문자열 거꾸로 출력. (0) 2020.09.21 문제 22번 - 팬린드롬 (0) 2020.09.21 문제 21번 - 중복된 수 제거 후 출력 (0) 2020.09.21 문제 20번 - 369 게임 (0) 2020.09.21