[백준] 1924번 2007년 / C++

#문제

백준 1924번 2007년

#풀이

#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:

  • [백준] 1181번 단어 정렬 / C++
  • [백준] 11050번 이항 계수 1 / C++
  • [백준] 11656번 접미사 배열 / C++
  • [백준] 1037번 최소공배수 / C++
  • [백준] 1934번 최소공배수 / C++