Simon_Lu @ 2019-07-25 08:12:12
using namespace std; int main(){ int date1,date2,year,month,day,flag=0,i,md,md2=28; int d1,d2,d3,d4,dx; cin>>date1>>date2; for(i=date1;i<=date2;i++){ year=i/10000; if((year%4==0&&year%100!=0)||year%400==0) md2=29; else md2=28; month=(i%10000-i%100)/100; if(month==12&&day==30) i=i+10000-1100-md+1; switch(month){ case 1:md=31; case 2:md=md2; case 3:md=31; case 4:md=30; case 5:md=31; case 6:md=30; case 7:md=31; case 8:md=30; case 9:md=31; case 10:md=30; case 11:md=31; case 12:md=30; } day=i%100; if(day>md) i=i+100-md+1; d1=i%10; d2=(i%100-d1)/10; d3=(i%1000-d1-d2)/100; d4=(i%10000-d1-d2-d3)/1000; dx=d11000+d2100+d3*10+d4; if(dx==year) flag++; } cout<<flag; return 0; }
by Simon_Lu @ 2019-07-25 14:05:52
@princess欣_清凌 谢谢,太感谢了,好人一生平安!