Submission
Status:
-----
Score: 0
User: www._.
Problemset: หินงอก
Language: cpp
Time: 0.002 second
Submitted On: 2025-04-27 09:43:03
#include <iostream>
using namespace std;
int main() {
int m, d; // Starting month and starting day of the week (1 = Monday, 7 = Sunday)
int dtillmd = 0;
int targetmonth = 8; // Mother's Day month
int targetday = 12; // Mother's Day day
int numdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; // Days in each month
// starting month and starting day of the week
//cout << "Enter the starting month (1-12): ";
cin >> m;
//cout << "starting day of the week for the first day of the starting month (1 = Monday, 7 = Sunday): ";
cin >> d;
// Calculate days from the starting date to the target date
for (int i = m; i <= targetmonth - 1; i++) {
dtillmd += numdays[i - 1]; // Add full months
}
dtillmd += targetday; // Add target day
// Determine the day of the week for Mother's Day
int mothers_day_weekday = (d + dtillmd - 1) % 7; // Align the weekday calculation
/*if (mothers_day_weekday == 0) {
mothers_day_weekday = 1; // Sunday
}*/
// Output total days until Mother's Day
//cout << mothers_day_weekday << endl;
// Output the day of the week for Mother's Day
int weekdays[] = {1, 2 , 3 , 4, 5 , 6 , 7};
cout << weekdays[mothers_day_weekday - 1] << endl;
return 0;
}