[2024 동계 모각코]
[2024 동계 모각코] 3회차 개인 목표 및 결과
multipotentialite1
2025. 1. 19. 13:50
일시 : 2025.01.19 14:00 ~ 17:00
[3회차 목표]
- 반복문, 조건문, 배열, 누적합, 그리디 알고리즘 복습 및 백준 문제 풀이
[3회차 결과]
- 조건문과 반복문 백준 문제 풀이를 진행하였습니다.
사분면 고르기
import java.util.Scanner;
public class P14681_사분면고르기 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
int y = sc.nextInt();
if (x > 0 && y > 0) {
System.out.println("1");
} else if (x < 0 && y > 0) {
System.out.println("2");
} else if (x < 0 && y < 0) {
System.out.println("3");
} else {
System.out.println("4");
}
}
}
구구단_for문 사용
import java.util.Scanner;
public class P2739_구구단_for문 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
for (int i = 1; i <= 9; i++) {
System.out.println(N + " * " + i + " = " + N * i);
}
}
}
구구단_while문 사용
import java.util.Scanner;
public class P2739_구구단_while문 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int i = 1;
while (i <= 9) {
System.out.println(N + " * " + i + " = "+ N*i);
i++;
}
}
}
합
import java.util.Scanner;
public class P8393_합 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int sum = 0;
for (int i = 1; i <= n; i++) {
sum += i;
} System.out.println(sum);
}
}
별찍기 1
import java.util.Scanner;
public class P2438_별찍기1 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
for (int i = 1; i <= N; i++) {
for (int j = 1; j <= i; j++) {
System.out.print("*");
}
System.out.println();
}
}
}
별찍기 2
import java.util.Scanner;
public class P2439_별찍기2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
for (int i = 1; i <= N; i++) {
for (int j = N; j > i ; j--) {
// for (int j = 1; j < N - i; j++) { 도 가능합니다.
System.out.print(" ");
}
for (int j = 1; j <= i; j++) {
System.out.print("*");
} System.out.println();
}
}
}