본문 바로가기

Algorithm179

백준 1924 ▶요일 출력하기 문제 ▶풀이 방법 import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int month = sc.nextInt(); int day = sc.nextInt(); int days[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; String week[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}; for(int i = 0; i < month-1; i++){ day += days[i]; } System.out.println(week[day%7]).. 2022. 3. 17.
백준 2739 ▶풀이방법 import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); for(int i = 1; i < 10; i++) { System.out.println(num + " * " + i + " = " + (num*i)); } } } 2022. 3. 16.
백준 2741, 2742 ▶ 2741번 문제 ▶풀이방법 import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); for(int i = 1; i 2741번 거꾸로 찍기 ▶풀이방법 import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); for(int i = num; i > 0; i--){ System.out.println(i); } } } 2022. 3. 16.
백준 11721 ▶풀이방법1 import java.util.*; public class Main(){ public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.next(); for(int i = 0; i < str.length(); i++) { System.out.print(str.charAt(i)); if(i % 10 == 9) { //10번째 글자 출력하면 enter System.out.println(); } } } } 2022. 3. 16.