baixiaoshengawa @ 2021-12-30 22:56:33
(怎么都是82a)
dalao帮个忙,orz
#include <iostream>
using namespace std;
int month[13] = { 0,1,2,3,4,5,6,7,8,9,10,11,12 };
int day[13] = { 0,31,-1,31,30,31,30,31,30,30,31,30,31 };
int date1, date2;
int cnt;
bool isRun(int year)
{
return (year % 100 != 0 && year % 4 == 0) || (year % 400 == 0);
}
bool isHui(int num)
{
if ((num / 10000000 == num % 10) && (num / 1000000 % 10 == num % 100 / 10) && (num / 100000 % 10 == num % 1000 / 100) && (num / 10000 % 10 == num % 10000 / 1000))
{
return 1;
}
return 0;
}
bool isRight(int date)
{
int dYear = date / 10000;
int dMonth = date % 10000 / 100;
int dDay = date % 100;
if (!(dMonth >= 1 && dMonth <= 12)) return 0;
if (dMonth == 2)
{
if (isRun(dYear))day[2] = 29;
else day[2] = 28;
}
if (!(dDay >= 1 && dDay <= day[dMonth])) return 0;
return 1;
}
int main()
{
cin >> date1 >> date2;
if (date1 == date2)
{
if (isHui(date1))
{
cout << 1;
return 0;
}
else
{
cout << 0;
return 0;
}
}
for (int i = date1; i <= date2; i++)
{
if (isRight(i) && isHui(i))
{
cnt++;
}
}
cout << cnt;
return 0;
}
//纯暴力毫无技术含量