题目地址: https://www.lanqiao.cn/problems/498/learning/
输入输出样例都成功,还有调试也正确,但是就是过不了OJ,折磨了一天了,麻烦帮忙看一下是什么问题
源代码
#include <iostream>
#include <stdlib.h>
using namespace std;
int year,month,day;
bool checkYear(int Year) {
if(Year%400==0||(Year%100!=0&&Year%4==0)) {
return true;
}else{
return false;
}
}
bool checkAll(int a,int b,int c,int temp) {
if(temp==0){
month=a%10*10+a/10%10;
day=a/100%10*10+a/1000;
if((month==b)&&(day==c)&&(month!=day)) {
return true;
}else{
return false;
}
}else{
month=a%10*10+a/10%10;
day=a/100%10*10+a/1000;
if(((month==b)&&(day==c))&&(a/1000==a/10%10)&&(a%10==a/100%10)) {
return true;
}else{
return false;
}
}
}
int main()
{
int days[13]={0,31,0,31,30,31,30,31,31,30,31,30,31};
int N,j,k,sum=0;
cin>>N;
year=N/10000;
month=N/1000/10*10+N/100%10;
day=N/10%10*10+N%10;
for(int i=year;i<9000;i++) {
if(checkYear(i)) {
days[2]=29;
}else{
days[2]=28;
}
if(i==year) {
j=month;
}else{
j=1;
}
for(j;j<=12;j++){
if(i==year) {
k=day;
}else{
k=1;
}
for(k;k<=days[j];k++) {
if(checkAll(i,j,k,sum)) {
cout<<i*10000+j*100+k<<endl;
sum++;
if(sum==2) {
exit(0);
}
}
}
}
}
return 0;
}