- 伊甸园日历游戏
- 2019-08-18 13:51:25 @
下面代码有问题吗?
// 伊甸园日历游戏
#include <bits/stdc++.h>
using namespace std;
bool judgeLeap(int year)
{
if(year % 100 == 0)
{
if(year % 400 == 0)
{
return true;
}
else
{
return false;
}
}
else
{
if(year % 4 == 0)
{
return true;
}
else
{
return false;
}
}
return false;
}
bool getRightWay(int year,int mouth,int day,bool leap)
{
if(mouth < 1 || day < 1)
{
return false;
}
if(year > 2001 || year < 1900)
{
return false;
}
else if(year == 2001)
{
if(mouth > 11)
{
return false;
}
else if(mouth == 11)
{
if(day > 4)
{
return false;
}
}
}
if(leap == true)
{
if(mouth == 2)
{
if(day > 29)
{
return false;
}
else
{
return true;
}
}
}
else if(leap == false)
{
if(mouth == 2)
{
if(day > 28)
{
return false;
}
else
{
return true;
}
}
}
return true;
}
string getWinWay(int mouth,int day)
{
if(mouth == 9 && day == 30)
{
return "YES";
}
if(mouth == 11 && day == 30)
{
return "YES";
}
int a = mouth + day;
if(a % 2 == 0)
{
return "YES";
}
else
{
return "NO";
}
}
int main()
{
int num;
cin >> num;
int year[num],mouth[num],day[num];
bool leap[num];
for(int i = 0;i < num;i++)
{
cin >> year[i] >> mouth[i] >> day[i];
leap[i] = judgeLeap(year[i]);
bool a = getRightWay(year[i],mouth[i],day[i],leap[i]);
if(a == false)
{
return 0;
}
}
for(int i = 0;i < num;i++)
{
cout << getWinWay(mouth[i],day[i]) << endl;
}
return 0;
}
0 条评论
目前还没有评论...