728x90
반응형
10.09
N을 입력받은 뒤, 구구단 N단을 출력하는 프로그램을 작성하시오. 출력 형식에 맞춰서 출력하면 된다.
package baekjoon;
import java.util.Scanner;
public class java_1009 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
for (int i = 1; i <= 9; i++) {
System.out.println(n + " * " + i + " = " + n * i);
}
}
}
10.10
두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.
package baekjoon;
import java.util.Scanner;
public class java_1010 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int count = scanner.nextInt();
int[] a;
a = new int[count];
int[] b;
b = new int[count];
for(int i = 0; i < count; i++) {
a[i] = scanner.nextInt();
b[i] = scanner.nextInt();
}
for(int i = 0; i<count; i++) {
System.out.println(a[i]+b[i]);
}
}
}
10.11
n이 주어졌을 때, 1부터 n까지 합을 구하는 프로그램을 작성하시오.
package baekjoon;
import java.util.Scanner;
public class java_1011 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int result = 0;
for(int i=1; i<=n; i++) {
result += i;
}
System.out.println(result);
}
}
10.12
준원이는 저번 주에 살면서 처음으로 코스트코를 가 봤다. 정말 멋졌다. 그런데, 몇 개 담지도 않았는데 수상하게 높은 금액이 나오는 것이다! 준원이는 영수증을 보면서 정확하게 계산된 것이 맞는지 확인해보려 한다.
영수증에 적힌,
- 구매한 각 물건의 가격과 개수
- 구매한 물건들의 총 금액
을 보고, 구매한 물건의 가격과 개수로 계산한 총 금액이 영수증에 적힌 총 금액과 일치하는지 검사해보자.
package baekjoon;
import java.util.Scanner;
public class java_1012 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int X = scanner.nextInt();
int N = scanner.nextInt();
int[] a = new int[N];
int[] b = new int[N];
int total = 0;
for(int i=0; i < N; i++) {
a[i] = scanner.nextInt();
b[i] = scanner.nextInt();
total += a[i] * b[i];
}
if(X==total) {
System.out.println("Yes");
}else {
System.out.println("No");
}
}
}
10.13
만약, 입출력이 바이트 크기의 정수라면 프로그램을 어떻게 구현해야 할까요?
package baekjoon;
import java.util.Scanner;
public class java_1013 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
for(int i=0; i<(N/4); i++) {
System.out.print("long ");
}
System.out.print("int");
}
}728x90
반응형
'Study > ☁️ 1일 1문제' 카테고리의 다른 글
| [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문제] 백준 단계별로 풀어보기 3-7번 (10.02~10.06) (0) | 2023.10.06 |
| [1일 1문제] 백준 단계별로 풀어보기 11-13번, 1-2번 (09.25~09.29) (0) | 2023.09.29 |
| [1일 1문제] 백준 단계별로 풀어보기 6-10번 (09.18~09.22) (1) | 2023.09.22 |