求大佬看一下,大佬洪福齐天,夜夜当新郎,全国各地都有丈母娘。
http://codeup.cn/problem.php?cid=100000578&pid=1
#include<iostream>
using namespace std;
int monthDays = { {0,0},{31,31},{28,29}, {31,31},{30,30},{31,31},{30,30}, {31,31},{31,31},{30,30},{31,31},{30,30},{31,31} };
string monthRevertArray = {" ", "January","February","March","April","May","June","July","August","September","October","November","December" };
string weekRevertArray = { "","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday" };
int nowYear=2020, nowMonth=01, nowDay=8,nowWeek=3;
string nowWeekString="wednesday";
int monthRevert(string monthString) {
for (int i = 0; i < 14; i++) {
if (monthString == monthRevertArray)
{
return i;
}
}
}
int weekRevert(string weekString) {
for (int i = 0; i < 8; i++) {
if (weekString == weekRevertArray)
{
return i;
}
}
}
bool IsLeap(int year) {
return((year % 4 == 0 && year % 100 != 0) || year % 400 == 0);
}
int main() {
int day,month, year,week,ans=1;
string monthString, weekString;
cin >> day >> monthString>>year;
month = monthRevert(monthString);
while (year < nowYear|| month < nowMonth || day < nowDay){
while (year < nowYear - 1) {
if (IsLeap(year)) ans += 366;
else ans += 365;
year++;
}
while (year < nowYear || month < nowMonth || day < nowDay) {
day++;
if(day == monthDays + 1)
{
month++;
day = 1;
}
if (month == 13) {
year++;
month = 1;
}
ans++;
}
}
week =(nowWeek+ ans % 7)%7;
weekString = weekRevertArray;
cout << weekString;
return 0;
} 加上注释 ,然后说明问题在哪里
页:
[1]