[BOJ 2870] ์ํ์์
1. ๋ฌธ์ : https://www.acmicpc.net/problem/2870
2. ํ์ด
์ ๊ทํํ์
3. ์ฝ๋
package baekjoon;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.math.BigDecimal;
import java.util.*;
import java.io.*;
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));
String str = "";
String regex = "([\\d]+)";
Pattern pattern = Pattern.compile(regex);
Matcher matcher;
int N = Integer.parseInt(br.readLine());
ArrayList<BigDecimal> arr = new ArrayList<BigDecimal>();
for(int i=0; i<N; i++) {
str = br.readLine();
matcher = pattern.matcher(str);
while(matcher.find()) {
arr.add(new BigDecimal(matcher.group()));
}
}
arr.sort(Comparator.naturalOrder());
for(BigDecimal val : arr) {
bw.write(val+"");
bw.newLine();
}
bw.flush();
}
}
'๐ป Coding Problems Solving > Array | String | Loop' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[BOJ 2607] ๋น์ทํ ๋จ์ด (0) | 2023.09.19 |
---|---|
[BOJ 24337] ๊ฐํฌ์ ํ (0) | 2023.06.14 |
[BOJ 2141] ์ฐ์ฒด๊ตญ (0) | 2023.06.08 |
[ํ๋ก๊ทธ๋๋จธ์ค] LV.2 ์ฐ์ ๋ถ๋ถ ์์ด ํฉ์ ๊ฐ์ (์๋ฐ java) (0) | 2023.02.27 |
[ํ๋ก๊ทธ๋๋จธ์ค] LV.2 ๊ทค ๊ณ ๋ฅด๊ธฐ (์๋ฐ java) (0) | 2023.02.22 |
์ต๊ทผ๋๊ธ