728x90
반응형
1.1
문제번호 3052
나머지
package baekjoon;
import java.util.Arrays;
import java.util.Scanner;
public class java_0101 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] A = new int[10];
int[] B = new int[10];
for (int i = 0; i < 10; i++) {
A[i] = sc.nextInt();
B[i] = A[i] % 42;
}
int[] count = Arrays.stream(B).distinct().toArray();
System.out.println(count.length);
}
}
1.2
문제번호 10811
바구니 뒤집기
package baekjoon;
import java.util.Arrays;
import java.util.Scanner;
public class java_0102 {
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;
while (i < j) {
int temp = a[i];
a[i++] = a[j];
a[j--] = temp;
}
}
for(int i=0; i<N; i++) {
System.out.print(a[i] + " ");
}
}
}
1.3
문제번호 1546
평균
package baekjoon;
import java.util.Scanner;
public class java_0103 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
double[] scores = new double[n];
double max = 0;
for (int i=0; i<n; i++) {
scores[i] = sc.nextDouble();
if(scores[i] > max) {
max = scores[i];
}
}
double sum = 0;
for (int i=0; i<n; i++) {
sum += (scores[i] / max) * 100;
}
System.out.println(sum/n);
}
}
1.4
문제번호 27866
문자와 문자열
package baekjoon;
import java.util.Scanner;
public class java_0104 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String S = sc.next();
int i = sc.nextInt();
System.out.println(S.substring(i-1, i));
}
}
1.5
문제번호 2743
단어 길이 재기
package baekjoon;
import java.util.Scanner;
public class java_0105 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String S = sc.next();
System.out.println(S.length());
}
}728x90
반응형
'Study > ☁️ 1일 1문제' 카테고리의 다른 글
| [1일 1문제] 백준 단계별로 풀어보기 8-11, 1번 (1.15~1.19) (2) | 2024.01.19 |
|---|---|
| [1일 1문제] 백준 단계별로 풀어보기 3-7번 (1.8~1.12) (1) | 2024.01.12 |
| [1일 1문제] 백준 단계별로 풀어보기 4-7번 (12.26~12.29) (1) | 2023.12.29 |
| [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 |