# Simple OJ questions for Freshmen

2022-02-03 00:38:55

This code can only be passed through 2/3 Example , Ask the boss to help find the missing situation , Thank you very much , The second time .
The question is to find the palindrome date between two dates , Enter the start and end dates , Number of output palindrome dates .
#include<stdio.h>
int main()
{
int a,b,i,j,k,n1,n2,sum=0;
scanf("%d %d",&a,&b);

n1=a/10000;
n2=b/10000;
int x[4]={0};
for(i=n1;i<=n2;i++){
int day[99]={31,28,31,30,31,30,31,31,30,31,30,31};
if((i%4==0&&i%100!=0)||i%400==0)
day[1]=29;
x[0]=i/1000;
x[1]=i/100-x[0]10;
x[3]=i%10;
x[2]=(i%100-x[3])/10;
// Judge whether the possible palindrome is within the date and the date is normal
if(i*10000+x[3]*1000+x[2]*100+x[1]*10+x[0]>=a&&i
10000+x[3]*1000+x[2]*100+x[1]*10+x[0]<=b&&day[x[3]*10+x[2]-1]>=x[1]*10+x[0])
sum++;
}
printf("%d",sum);
return 0;
}

Refer to the answer 1：

Can you resend the code ？

All wrong , After roughly making up, run the test, and even the test case can't pass

Refer to the answer 2：

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.primo.wiki/2022/02/202202030038531958.html