1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int today = 0; int x = sc.nextInt(); int y = sc.nextInt(); int month = 1; for(month = 1; month < x; month++) { switch(month) { //31일 까지 있는 달 case 1: case 3: case 5: case 7: case 8: case 10: case 12: today += 31; break; //2월 case 2: today += 28; break; //30일까지 있는 달 case 4: case 6: case 9: case 11: today += 30; break; } } today += y; switch(today % 7) { case 1: System.out.println("MON"); break; case 2: System.out.println("TUE"); break; case 3: System.out.println("WED"); break; case 4: System.out.println("THU"); break; case 5: System.out.println("FRI"); break; case 6: System.out.println("SAT"); break; case 0: System.out.println("SUN"); break; } sc.close(); } } | cs |
딱히 다른 방법이 생각나지 않는다...
'Programming > Solutions' 카테고리의 다른 글
[BAEKJOON] 2775번 (0) | 2019.03.25 |
---|---|
[BAEKJOON] 2292번 (0) | 2019.03.24 |
[Project Euler] Problem 007 (0) | 2019.03.24 |
[Project Euler] Problem 006 (0) | 2019.03.24 |
[Project Euler] Problem 005 (0) | 2019.03.20 |