C语言60分求助

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

@[EkSulfur](/user/1054137) yn函数写成这样: ```cpp int a=0; if (x % 4 == 0&&x%100!=0||x%400==0) a =!a; return a; ```
by Use_Imagination @ 2023-08-18 23:12:01


```c #include <bits/stdc++.h> using namespace std; int main() { int x, y; cin >> x >> y; int cnt = 0; for (int i = x; i <= y; i++) { if (i % 400 == 0 || i % 100 != 0 && i % 4 == 0) { cnt++; } } cout << cnt << endl; for (int i = x; i <= y; i++) { if (i % 400 == 0 || i % 100 != 0 && i % 4 == 0) cout << i << " "; } return 0; } ```
by wzj0829 @ 2023-08-18 23:15:16


@[EkSulfur](/user/1054137) 可以看看我的 ```cpp #include<bits/stdc++.h> using namespace std; bool r(long long i){ if(i%4==0 && i%100!=0 || i%400==0 && i%3200!=0) return 1; else return 0; } int main() { ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); long long x,y,a=0; cin>>x>>y; for(int i=x;i<=y;++i){ if(r(i)) a++; } cout<<a<<endl; for(int j=x;j<=y;++j){ if(r(j)) cout<<j<<" "; } return 0; } ```
by FurippuWRY @ 2023-08-19 00:45:19


感谢
by EkSulfur @ 2023-08-21 18:42:36


|