Skip to content

Commit

Permalink
[D2]
Browse files Browse the repository at this point in the history
arraylist로 바꿀때, for each를 이용해서 수동으로 바꿔주는 것이 좋다.
  • Loading branch information
sunjung0120 committed Oct 24, 2024
1 parent 6c45025 commit 8886838
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Ssafy_test/src/D2/SWEA_1204.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package D2;

import java.io.*;
import java.util.*;

public class SWEA_1204 {

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 num = Integer.parseInt(br.readLine());

for(int i = 0; i<num;i++) {
List<Integer> li = new ArrayList<>();
int[] lis = new int[101];

int n = Integer.parseInt(br.readLine());
StringTokenizer st = new StringTokenizer(br.readLine());

for(int j = 0; j<1000; j++ ) {
int a = Integer.parseInt(st.nextToken());
lis[a]++; //하나 증가
}

// Arrays.asList(lis); //이건 보이기에만 이렇게 바꾼거라, get, max 등을 몼써..

for(int l:lis) {
li.add(l); //직접 값을 복사
}

bw.write("#" + n + " ");

for(int j = 100; j>=0; j-- ) {
if(li.get(j) == Collections.max(li)) {
bw.write(j + "\n"); //인덱스를 저장
}
}
}
bw.flush();
bw.close();
br.close();
}
}

0 comments on commit 8886838

Please sign in to comment.