๋ฌธ์ :
programmers.co.kr/learn/courses/30/lessons/12901?
๋ถ์ :
์ค๋ ๊ณผ 7์์์ 8์๋ก ๋์ด๊ฐ ์ ํ์ ์ง์ ๊ณ์ฐ์ ๋ฌ๋ฆฌ ํด์ค๋ค.
c++ ํ์ด :
#include <string>
#include <vector>
#include <iostream>
using namespace std;
string solution(int a, int b) {
string answer = "";
int sum = 0;
//int day = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if(a>1){
for(int i =1; i < a; i++){
if(i <= 7){
if(i % 2 == 1) {
sum += 31;
} else{
if (i == 2){
sum += 29;
}else{
sum += 30;
}
}
}
else{
if(i % 2 == 0) {
sum += 31;
}else{
sum += 30;
}
}
}
sum += b;
}
else{
sum = b;
}
if(sum % 7 == 1){
answer = "FRI";
}else if( sum % 7 == 2){
answer = "SAT";
}else if(sum % 7 == 3){
answer = "SUN";
}else if(sum % 7 == 4){
answer = "MON";
}else if(sum % 7 == 5){
answer = "TUE";
}else if(sum % 7 == 6){
answer = "WED";
}else if(sum % 7 == 0){
answer = "THU";
}
return answer;
}
'Algorithm๐ฐ > ํ๋ก๊ทธ๋๋จธ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[ํ๋ก๊ทธ๋๋จธ์ค] Summer/Winder coding ๋ฐฉ๋ฌธ ๊ธธ์ด level2 (0) | 2021.04.30 |
---|---|
[ํ๋ก๊ทธ๋๋จธ์ค] ์์ ๊ฒ์ 2021 ์นด์นด์ค ๋ธ๋ผ์ธ๋ ํ ์คํธ level2 (0) | 2021.04.28 |
[ํ๋ก๊ทธ๋๋จธ์ค] ๋ ๊ฐ ๋ฝ์์ ๋ํ๊ธฐ (0) | 2021.02.26 |
[ํ๋ก๊ทธ๋๋จธ์ค] ํฌ๋ ์ธ ์ธํ ๋ฝ๊ธฐ 2019 ์นด์นด์ค ๊ฐ๋ฐ์ ๊ฒจ์ธ ์ธํด์ฝ (0) | 2021.02.24 |
[ํ๋ก๊ทธ๋๋จธ์ค] ํ์ค๋ ์ basic (0) | 2021.02.24 |
๋๊ธ