20230501

2023. 5. 1. 16:33TIL

1. 오늘 한 것

문제 풀이

2. 공부 내용 정리

문제 1.N을 입력받은 뒤, 구구단 N단을 출력하는 프로그램을 작성하시오. 출력 형식에 맞춰서 출력하면 된다.

import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
sc.close();

for (int i = 1; i <= 9; ++i) {
System.out.println(a+" * "+i+" = "+a*i);

}

}
}
 
2. 백준 10430번

(A+B)%C는 ((A%C) + (B%C))%C 와 같을까?

(A×B)%C는 ((A%C) × (B%C))%C 와 같을까?

세 수 A, B, C가 주어졌을 때, 위의 네 가지 값을 구하는 프로그램을 작성하시오.

 

import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
System.out.println((a+b)%c);
System.out.println(((a%c)+(b%c))%c);
System.out.println((a*b)%c);
System.out.println(((a%c)*(b%c))%c);
}
}

문제 3. 백준 2439번

첫째 줄에는 별 1개, 둘째 줄에는 별 2개, N번째 줄에는 별 N개를 찍는 문제

하지만, 오른쪽을 기준으로 정렬한 별(예제 참고)을 출력하시오.

import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int j;
for(int i=1;i<=a;i++)
{
for(j=a;j>i;j--)
{
System.out.print(" ");
}
for(int k=0;k<i;k++)
{
System.out.print("*");
}
System.out.println();
}
}
}

3. 내일 할 것

페어 프로그래밍

4. 느낀점

역시 생각하면서 문제 푸는게 재미있다

5. 메모

'TIL' 카테고리의 다른 글

20230503  (0) 2023.05.03
20230502 TIL  (0) 2023.05.02
20230427 TIL  (0) 2023.04.27
20230425 TIL  (1) 2023.04.25
1주차 월요일 학습내용  (0) 2023.04.24