"SWEA 5515 2016년 요일 맞추기"의 두 판 사이의 차이

(새 문서: ==개요== ;{{PAGENAME}} {{SWEA 헤더}} {{SWEA 난이도 3-2}} |} ==C++== <source lang='cpp'> </source> ==Java== <source lang='java'> </source>)
 
잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(다른 사용자 한 명의 중간 판 2개는 보이지 않습니다)
7번째 줄: 7번째 줄:


==C++==
==C++==
<source lang='cpp'>
<syntaxhighlight lang='cpp'>
</source>
</syntaxhighlight>


==Java==
==Java==
<source lang='java'>
<syntaxhighlight lang='java'>
</source>
import java.util.*;
class Solution
{
    public static void main (String[] args) {
        int[] daysOfMonth = {0,31,29,31,30,31,30,31,31,30,31,30,31};
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        int m, d, i, days, weekday;
        for(int tc=1; tc<=T; tc++) {
            m = sc.nextInt();
            d = sc.nextInt();
            days = 0;
            for(i=1; i<m; i++) {
                days += daysOfMonth[i];
            }
            weekday = (days+d+3) % 7;
            System.out.format("#%d %d\n", tc, weekday);
        }
        sc.close();
    }
}
</syntaxhighlight>

2021년 7월 31일 (토) 10:59 기준 최신판

1 개요[ | ]

SWEA 5515 2016년 요일 맞추기
SW Expert 아카데미
# 문제 풀이

틀:SWEA 난이도 3-2

2 C++[ | ]

3 Java[ | ]

import java.util.*; 
class Solution 
{
    public static void main (String[] args) {
        int[] daysOfMonth = {0,31,29,31,30,31,30,31,31,30,31,30,31};
        Scanner sc = new Scanner(System.in);
        int T = sc.nextInt();
        int m, d, i, days, weekday;
        for(int tc=1; tc<=T; tc++) {
            m = sc.nextInt();
            d = sc.nextInt();
            days = 0;
            for(i=1; i<m; i++) {
                days += daysOfMonth[i];
            }
            weekday = (days+d+3) % 7;
            System.out.format("#%d %d\n", tc, weekday);
        }
        sc.close();
    } 
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}