웅재의 코딩세상
[프로그래머스] 2016년 본문
- 풀이
#include <string>
#include <vector>
#include <map>
using namespace std;
string day[] = {"FRI", "SAT", "SUN", "MON", "TUE", "WED", "THU"};
int month[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
string solution(int a, int b) {
int sum =0;
for(int i=0; i<a-1; i++){
sum += month[i];
}
sum += b-1;
return day[(sum%7)];
}
반응형
'코딩테스트 > 프로그래머스 - LV 1' 카테고리의 다른 글
[프로그래머스] 카드 뭉치 (0) | 2024.02.14 |
---|---|
[프로그래머스] 추억 점수 (0) | 2024.02.14 |
[프로그래머스] 두 개 뽑아서 더하기 (0) | 2024.02.14 |
[프로그래머스] 콜라 문제 (1) | 2024.02.14 |
[프로그래머스] 최소직사각형 (0) | 2024.02.14 |