1lgorithm @ 2020-06-05 18:16:51
大佬们帮帮我,第十一个点wa了
#include<iostream>
using namespace std;
int month[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int months[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
int runnian(int n){
if(n%4!=0){
return 0;
}
if(n%100!=0){
return 1;
}
if(n%400!=0){
return 0;
}
return 1;
}
int main(){
int a,b;
cin>>a>>b;
int sy=a/10000,ey=b/10000;
int s=0;
for(int i=sy;i<=ey;i++){
int k=i*10000+i%10*1000+i/10%10*100+i/100%10*10+i/1000;
if(i==sy){
if(k%10000/100<=12){
if(runnian(i)){
if(k%100<=months[k%10000/100]){
if(k%10000/100>0&&k%100>0){
if(k%10000>=a%10000){
s++;
}
}
}
}
else{
if(k%100<=month[k%10000/100]){
if(k%10000/100>0&&k%100>0){
if(k%10000>=a%10000){
s++;
}
}
}
}
}
continue;
}
else{
if(i==ey){
if(k%10000/100>0&&k%100>0){
if(k%10000<=b%10000){
s++;
}
}
}
else{
if(k%10000/100<=12){
if(runnian(i)){
if(k%100<=months[k%10000/100]){
if(k%10000/100>0&&k%100>0){
s++;
}
}
}
else{
if(k%100<=month[k%10000/100]){
if(k%10000/100>0&&k%100>0){
s++;
}
}
}
}
}
}
}
cout<<s;
}
by metaphysis @ 2020-06-05 21:19:55
您的代码可读性太差了,解题逻辑估计只有您自己清楚,能否加个注释看看?
@1lgorithm
by pqliuyqq @ 2020-06-18 17:53:48
提示:开始和结束有可能是同一年
by pqliuyqq @ 2020-06-18 17:54:04
我也栽了……
by Wildcxj @ 2020-06-25 09:39:46
闰年判断程序错了
by 1lgorithm @ 2020-07-19 09:46:59
这道题我终于对了,感谢大佬们