Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- java 기초
- DB 개요
- oracle
- github
- Flutter
- 쿠버네티스
- dql
- docker
- DB 모델링
- 웹개발 기초
- docker 소개
- DDL
- 데이터베이스
- 쿠버네티스 기본 개념
- SQL
- DB
- 도커
- VS Code
- 기본 API
- 마크다운
- MVC 패턴
- ORACLE 기초
- 기초 선택자
- mybatis
- view
- 정보처리기사
- 깃허브
- 프로그래밍 기초
- java
- 필기
Archives
- Today
- Total
핑구
[백준/JAVA] 4344번 : 평균은 넘겠지 본문
https://www.acmicpc.net/problem/4344
4344번: 평균은 넘겠지
대학생 새내기들의 90%는 자신이 반에서 평균은 넘는다고 생각한다. 당신은 그들에게 슬픈 진실을 알려줘야 한다.
www.acmicpc.net
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
int[] studentNum = new int[num];
double[] avg = new double[num];
for(int i = 0; i < studentNum.length; i++) {
studentNum[i] = sc.nextInt();
int[] studentScore = new int[studentNum[i]];
for(int j = 0; j < studentScore.length; j++) {
studentScore[j] = sc.nextInt();
avg[i] += studentScore[j];
}
avg[i] = avg[i] / studentNum[i];
int count = 0;
for(int k = 0; k < studentScore.length; k++) {
if(avg[i] < studentScore[k]) {
count++;
}
}
avg[i] = 100.0 / studentNum[i] * count;
}
for(int i = 0; i < avg.length; i++) {
System.out.printf("%.3f%%%n", avg[i]);
}
}
}