공부/SWEA
[SWEA-1204] [S/W 문제해결 기본] 1일차 - 최빈수 구하기 - Java
빈v
2022. 6. 2. 16:58
728x90
https://swexpertacademy.com/main/code/problem/problemDetail.do
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
SWEA 1204번 [S/W 문제해결 기본] 1일차 최빈수 구하기 자바 풀이
난이도: D2
코드
import java.util.Scanner;
public class swea1204 {
public static void main(String args[]) throws Exception
{
Scanner sc = new Scanner(System.in);
int T;
T=sc.nextInt();
for(int test_case = 1; test_case <= T; test_case++)
{
int arr[]=new int[101];
int num=sc.nextInt();
for(int i=0;i<1000;i++){
int score=sc.nextInt();
arr[score]++;
}
int max=0;
int result=0;
for(int i=0;i<101;i++){
if(max<=arr[i]){
max=arr[i];
result=i;
}
}
System.out.println("#"+test_case+" "+result);
}
}
}
728x90
반응형