728x90
반응형
12.26
문제번호 2562
1차원 배열 - 최댓값
package baekjoon;
import java.util.Scanner;
public class java_1226 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] a = new int[9];
for (int i=0; i<9; i++) {
int num = sc.nextInt();
a[i] = num;
}
int max = a[0];
int n = 1;
for(int i=1; i<9; i++) {
if(max < a[i]) {
max = a[i];
n = i + 1;
}
}
System.out.println(max);
System.out.println(n);
}
}
12.27
문제번호 10810
1차원 배열 - 공 넣기
package baekjoon;
import java.util.Scanner;
public class java_1227 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt(); // 바구니 개수
int M = sc.nextInt(); // 공을 넣을 횟수
int[] a = new int[N+1];
for (int n = 0; n < M; n++) {
int i = sc.nextInt();
int j = sc.nextInt();
int k = sc.nextInt();
for (int u=i; u<=j; u++) {
a[u] = k;
}
}
for (int i=1; i <= N; i++) {
System.out.print(a[i] + " ");
}
}
}
12.28
문제번호 10813
1차원 배열 - 공 바꾸기
package baekjoon;
import java.util.Scanner;
public class java_1228 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
int[] a = new int[N];
for(int i = 0; i < N; i++) {
a[i] = i + 1;
}
for (int n = 0; n < M; n++) {
int i = sc.nextInt()-1;
int j = sc.nextInt()-1;
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
for (int i=0; i < N; i++) {
System.out.print(a[i] + " ");
}
}
}
12.29
문제번호 5597
1차원 배열 - 과제 안 내신 분..?
package baekjoon;
import java.util.Scanner;
public class java_1229 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int stu[] = new int[30];
for (int i=0; i < 28; i++) {
int n = sc.nextInt();
stu[n-1] = 1;
}
for (int i=0; i<30; i++) {
if(stu[i] == 0) {
System.out.println(i+1);
}
}
}
}728x90
반응형
'Study > ☁️ 1일 1문제' 카테고리의 다른 글
| [1일 1문제] 백준 단계별로 풀어보기 3-7번 (1.8~1.12) (1) | 2024.01.12 |
|---|---|
| [1일 1문제] 백준 단계별로 풀어보기 8-10번, 1-2번 (1.1~1.5) (1) | 2024.01.05 |
| [1일 1문제] 백준 단계별로 풀어보기 11-12번, 1-3번 (11.20~11.24) (3) | 2023.11.24 |
| [1일 1문제] 백준 단계별로 풀어보기 6-10번 (11.06~11.10) (0) | 2023.11.10 |
| [1일 1문제] 백준 단계별로 풀어보기 1-5번 (10.09~10.13) (1) | 2023.10.13 |