[백준] 1924번 2007년 / C++
#문제
#풀이
#include <iostream>
#include <string>
using namespace std;
int main()
{
ios::sync_with_stdio(false); cin.tie(NULL);
int month[13] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
string array[7] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
int x, y, ans;
cin >> x >> y;
for (int i = 0; i < x; ++i)
{
y += month[i];
}
cout << array[y % 7] << endl;
return 0;
}
#정리
입력받은 일자까지의 모든 일수를 더하고, 7로 나눠 원하는 요일을 출력할 수 있도록 프로그램을 구현했다.
Enjoy Reading This Article?
Here are some more articles you might like to read next: