Gidhub BE Developer

Programmers - 2016

2018-07-17
goodGid

Problem

Problem URL : 2016


[1] Answer Code (18. 07. 24)


string solution(int a, int b) {
    int month_day[12] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
    string day_arr[7] = { "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN" };

    int day = 3;
    for(int i=0; i<a-1; i++){
        day += month_day[i];
    }

    string answer = "";
    day += b;
    day %= 7;
    answer = day_arr[ day ];

    return answer;
}



[1] Answer Code (18. 07. 24)

  • Programmers Problem

  • 날짜 계산하는 로직이 떠오르지 않아 당황했다.


Comments

Content