2739번
N을 입력받은 뒤, 구구단 N단을 출력하는 프로그램을 작성하시오. 출력 형식에 맞춰서 출력하면 된다.
public class googoo {
public static void main(String[] args) {
int N;
Scanner sc = new Scanner(System.in);
N = sc.nextInt();
for(int i = 1; i <=9; i++ ) {
System.out.println(N+" " + "*"+" " + i +" "+ "="+" " + N * i );
}
}
}
10950번
두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오.
public class Main {
public static void main(String[] args) {
int A,B,C;
Scanner sc = new Scanner(System.in);
A = sc.nextInt();
for(int i=0; i<A; i++) {
B = sc.nextInt();
C = sc.nextInt();
System.out.println(B+C);
}
}
}
8393번
n이 주어졌을 때, 1부터 n까지 합을 구하는 프로그램을 작성하시오.
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
sc.close();
int sum = 0;
for (int i = 1; i <= n; ++i) {
sum += i;
}
System.out.println(sum);
}
}
'Study > 알고리즘' 카테고리의 다른 글
백준 1037번 - 약수 JAVA (0) | 2022.07.25 |
---|---|
백준 1100번 - 하얀 칸 JAVA (0) | 2022.07.24 |
백준 1009번 - 분산처리 JAVA (0) | 2022.07.23 |
JAVA 백준 알고리즘 단계별로 풀어보기 - 3 (0) | 2022.05.30 |
JAVA 백준 알고리즘 단계별로 풀어보기 - 1 (0) | 2022.05.15 |