自己按样例测试可以,测评机上却0分qwq

P5737 【深基7.例3】闰年展示

您最后的循环里面应该 i<num
by Miraclezzz @ 2020-10-12 16:19:27


``` #include<bits/stdc++.h> using namespace std; int main() { int a,y,sum=0; cin>>a>>y; for(int x=a;x<=y;x++) { if(x%4==0) { if(x%100==0) { if(x%400==0) { sum++; } else continue; } else sum++; } else continue; } cout<<sum<<endl; for(int x=a;x<=y;x++) { if(x%4==0) { if(x%100==0) { if(x%400==0) { cout<<x<<" "; } else continue; } else cout<<x<<" "; } else continue; } return 0; } 我的代码(AC)
by 听取AC声一片 @ 2020-10-14 13:26:47


这样就很容易理解
by 听取AC声一片 @ 2020-10-14 13:27:37


@[Hazers](/user/399881) 蟹蟹
by wu_wowo @ 2020-10-16 21:15:23


``` #include <bits/stdc++.h> using namespace std; int a[1500]; bool r(int y){ return y%100!=0&&y%4==0||y%400==0; } int main(){ int x,y,k=0; cin>>x>>y; for(int i=x;i<=y;++i) if(r(i)) a[k++]=i; cout<<k<<endl; for(int i=0;i<k;++i) cout<<a[i]<<' '; cout<<endl; return 0; } ``` C++
by Blood_red @ 2021-02-16 18:36:26


```c #include <iostream> using namespace std; int main() { int x,y,sum=0; cin>>x>>y; int a[1500]; for(int i=x;i<=y;i++) { if((i%100!=0&&i%4==0)||(i%400==0)) { sum+=1; a[sum]=i; } } cout<<sum<<endl; for(int j=1;j<=sum;j++) { cout<<a[j]<<" "; } return 0; } ``` 来水一下(doge)
by 国家级白嫖 @ 2021-03-26 00:34:38


|