World full day C ++

topic

Since listed since era, there have been many times in the world perfectly symmetrical Day.
Here Insert Picture Description

Today is 2020/02/20, we would consider to date, so the subject of analysis, can not be considered a leap month.

Code

#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int a[9];
int main()
{
     int n,i,j,k,l;
     int year,month,day;
     int sum=0;
     int date[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
  for(i=1;i<=9;i++)  
   for(j=0;j<=9;j++)
    for(k=0;k<=9;k++)
    {
     month=j*10+k;
     day=j*10+i;
     if(month>0&&month<=12)
     {
      if(day<=date[month])
      {
       sum++;
       cout<<i<<j<<k<<j<<i<<endl;
      }
     }
     month=k*10+k;
     day=j*10+i;
     if(month>0&&month<=12)
     {
      if(day<=date[month])
      {
       sum++;
       cout<<i<<j<<k<<k<<j<<i<<endl;
      }
     }
    }
  for(i=1;i<=9;i++)  
   for(j=0;j<=9;j++)
    for(k=0;k<=9;k++)
     for(l=0;l<=9;l++) 
     {
      month=l*10+k;
      day=j*10+i;
       if(month>0&&month<=12)
      {
       if(day<=date[month])
       {
        sum+=1; 
        cout<<i<<j<<k<<l<<k<<j<<i<<endl; 
       }
      } 
     }
  
  for(i=1;i<=2;i++)  
   for(j=0;j<=9;j++)
    for(k=0;k<=9;k++)
     for(l=0;l<=9;l++)
     {
      year=i*1000+j*100+k*10+l;
      month=l*10+k;
      day=j*10+i;
      if(year<=2020)
      if(month>0&&month<=12)
      if(day<=date[month])
       {
        sum+=1; 
        cout<<i<<j<<k<<l<<l<<k<<j<<i<<endl; 
       }
     }
  cout<<sum;
    return 0;
 
}

Operation result

Here Insert Picture Description

to sum up

Palindrome feeling to go first and then determine whether it is a date, than to go first date, and then determine whether it is a palindrome simple.

Released eight original articles · won praise 1 · views 253

Guess you like

Origin blog.csdn.net/xililixilu/article/details/104147938