题目
T615685 日期回文
错误原因:
没找出错误原因
思路
1.输入
2.嵌套for
3.定义一个res
4.res等于j%1010000000+j/101000000+i%10100000+i/1010000+i*100+j;
5.if res大于等于a,小于等于b
6.计数器++
7.输出计数器
正确代码
#include<bits/stdc++.h>
using namespace std;
int d[13]={0,31,29,31,30,31,30,31,31,30,31,30,31},a,b,cnt;
int main()
{
cin>>a>>b;//输入
for(int i=1;i<=12;i++)//嵌套for
{
for(int j=1;j<=d[i];j++)
{
int res=j%10*10000000+j/10*1000000+i%10*100000+i/10*10000+i*100+j;
if(res>=a && res<=b)
{
cnt++;//计数器++
}
}
}
cout<<cnt;//输出
return 0;
}