https://www.acmicpc.net/problem/2750
import java.util.Scanner;
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int x = in.nextInt();
int[] arr = new int[x];
for(int i=0; i<x; i++) {
arr[i] = in.nextInt();
}
Arrays.sort(arr);
for(int i=0; i<x; i++) {
System.out.println(arr[i]);
}
}
}
https://www.acmicpc.net/problem/10989
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int x = Integer.parseInt(br.readLine());
int[] arr = new int[x];
for(int i=0; i<x; i++) {
arr[i] = Integer.parseInt(br.readLine());
}
Arrays.sort(arr);
for(int i=0; i<x; i++) {
sb.append(arr[i]).append('\n');
}
System.out.println(sb);
}
}
https://www.acmicpc.net/problem/25305
import java.util.Arrays;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] strArr = br.readLine().split(" ");
String[] strArr1 = br.readLine().split(" ");
int x = Integer.parseInt(strArr[0]);
int y = Integer.parseInt(strArr[1]);
int[] arr = new int[x];
for(int i=0; i<x; i++) {
arr[i] = Integer.parseInt(strArr1[i]);
}
Arrays.sort(arr);
System.out.println(arr[x-y]);
}
}
https://www.acmicpc.net/problem/10872
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int x = Integer.parseInt(br.readLine());
x = factorial(x);
System.out.println(x);
}
public static int factorial(int x) {
if (x == 0) {
return 1;
}
else {
return x * factorial(x-1);
}
}
}
https://www.acmicpc.net/problem/10870
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int x = Integer.parseInt(br.readLine());
x = pibo(x);
System.out.println(x);
}
public static int pibo(int x) {
if (x <= 1) {
return x;
}
else {
return pibo(x-1) + pibo(x-2);
}
}
}
'Java-Study' 카테고리의 다른 글
Java Study : 11주차 - 자바 입출력 (0) | 2023.01.22 |
---|---|
Java Study : 10주차 정리 - 예외처리 (0) | 2023.01.14 |
Java Study : 9주차 정리 - 내부 클래스, 람다식, 스트림 (0) | 2023.01.08 |
Java Study : 8주차 - 백준 문제풀이 (0) | 2022.12.23 |
Java Study : 8주차 정리 - 컬렉션 프레임워크(제네릭, 컬렉션 프레임워크, (List, Set, Map)인터페이스) (0) | 2022.12.23 |