冰冰手里有糖 @ 2019-11-04 22:58:30
using namespace std;
int n,m,i,year1,year2,mon,days,ans=0;
int main() {
cin>>n>>m;
year1=n/10000;
year2=m/10000;
for(i=year1;i<=year2;i++)
{
mon=i%10*10+i/10%10;
days=i/100%10*10+i/1000;
if(mon==2)
{
if(((i%400==0||i%4==0&&i%100!=0)&&days<=29)||days<=28) ans++;
}
if((mon==1||mon==3||mon==5||mon==7||mon==8||mon==10||mon==12)&&days<=31) ans++;
else
if((mon==4||mon==6||mon==9||mon==11)&&days<=30) ans++;
// if(i==year2){ if(m<year2*10000+mon*100+days) ans--;}
}
cout<<ans<<endl;
return 0;
} 为什么我加了注释的一行就wa了??(不加就100分加了就30分) 如果是20011000 20011001 不应该是0而不是1吗
by JRzyh @ 2019-11-12 17:44:08
#include<bits/stdc++.h>
using namespace std;
int n,m,i,year1,year2,mon,days,ans=0;
int main() {
cin>>n>>m;
year1=n/10000;
year2=m/10000;
for(i=year1;i<=year2;i++)
{
mon=i%10*10+i/10%10;
days=i/100%10*10+i/1000;
if(mon==2)
{
if(((i%400==0||i%4==0&&i%100!=0)&&days<=29)||days<=28) ans++;
}
if((mon==1||mon==3||mon==5||mon==7||mon==8||mon==10||mon==12)&&days<=31) ans++;
else
if((mon==4||mon==6||mon==9||mon==11)&&days<=30) ans++;
// if(i==year2){ if(m<year2*10000+mon*100+days) ans--;}
}
cout<<ans<<endl;
return 0;
}
为什么我加了注释的一行就wa了??(不加就100分加了就30分) 如果是20011000 20011001 不应该是0而不是1吗?