Fryderyk_Chopin @ 2023-05-08 12:51:21
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,i,s=0;
cin>>a>>b;
for(i=a;i<=b;i++){
if(i%100!=0){
if(i%4==0)
{
s++;
}
}
else if(i%100==0){
if(i%400==0){
s++;
}
}
cout<<s<<endl;
}
for(i=a;i<=b;i++){
if(i%100!=0){
if(i%4==0){
cout<<i<<" ";
}
}
else if(i%100==0){
if(i%400==0){
cout<<i<<" ";
}
}
}
return 0;
}
求救!数据输入输出都没错,为什么是0分!
by Thenyu @ 2023-05-08 13:00:11
样例都没过,自己看
by _buzhidao_ @ 2023-05-08 13:00:17
@smxcys666 可以简化
#include<bits/stdc++.h>
using namespace std;
short a,b,c[400],d;
int main(){
cin>>a>>b;
for(short i=a;i<=b;i++){
if(i%4==0&&(i%100!=0||i%400==0)){
c[d]=i;d++;
}
}
cout<<d<<endl;
for(short i=0;i<d;i++) cout<<c[i]<<' ';
return 0;
}
by _buzhidao_ @ 2023-05-08 13:01:58
@smxcys666 可能有些抽象,
by Fryderyk_Chopin @ 2023-05-08 13:13:17
@buzhidao Sorry,I am not understand when there is a "数组" here~~~
by _buzhidao_ @ 2023-05-08 13:14:20
@smxcys666 为了记录数据
by _buzhidao_ @ 2023-05-08 13:14:58
@smxcys666 网速刚刚好慢啊,是不是又有人卡评测了
by Fryderyk_Chopin @ 2023-05-08 13:16:15
@buzhidao d没有初始值。
by _buzhidao_ @ 2023-05-08 13:16:52
@smxcys666 全局变量自动初始化
by Terry2011 @ 2023-06-01 14:29:21
#include<bits/stdc++.h>
using namespace std;
short a,b,c[400],d;
int main(){
cin>>a>>b;
for(short i=a;i<=b;i++){
if(i%4==0&&(i%100!=0||i%400==0)){
c[d]=i;d++;
}
}
cout<<d<<endl;
for(short i=0;i<d;i++) cout<<c[i]<<' ';
return 0;
}