dang_dang @ 2021-08-18 16:21:26
错了!19分!
using namespace std;
char arr[8];
char sf[8],se[8];
int day[130]={0,31,28,31,29,31,29,31,31,29,31,29,31};
int getback(int t)
{
int j=0,tp=0,bt=t;
while(t){
arr[tp++]=t%10;
t/=10;
}
tp--;
while(tp>j) if(arr[j++]!=arr[tp--]) return 0;
cerr<<bt<<endl;
return 1;
}
/*
10140211
30160810
*/
int main()
{
int f,e,ans=0;
int y,m,d;
cin>>f>>e;
y=f/10000;
d=f%100;
m=f%10000-d;
int now=f;
while(now<=e)
{
ans+=getback(now);
d++;
if(d>day[m])
{
d=1;m++;
if(m>12) {m-=12;y++;}
}
now=d+100*m+10000*y;
}
cout<<ans;
return 0;
}
by Darko1227 @ 2021-08-18 16:28:30
刚开始的
by chenkaiwen @ 2021-08-18 16:38:18
@dang_dang
#include<bits/stdc++.h>
using namespace std;
char arr[8];
char sf[8],se[8];
int day[13]= {0,31,28,31,29,31,29,31,31,29,31,29,31};
int getback(int t) {
int j=0,tp=0,bt=t;
while(t) {
arr[tp++]=t%10;
t/=10;
}
tp--;
while(tp>j) if(arr[j++]!=arr[tp--]) return 0;
// cout<<bt<<endl;
return 1;
}
/*
10140211
30160810
*/
int main() {
int f,e,ans=0;
int y,m,d;
cin>>f>>e;
y=f/10000;
d=f%100;
m=f%10000-d;
m/=100;
int now=f;
while(now<=e) {
ans+=getback(now);
d++;
if(d>day[m]) {
d=1;
m++;
if(m>12) {
m-=12;
y++;
}
}
now=d+100*m+10000*y;
}
cout<<ans;
return 0;
}
你的m要除以100
最后请你自己写一个特判闰年
如果不判回有两个点炸
by dang_dang @ 2021-08-18 16:38:43
谢谢老师