lofing @ 2024-09-26 14:25:20
我的输出和样例的一模一样,然后复制了个题解,生成了几个数据都一样,为什么会WA?
#include<bits/stdc++.h>
#define MAX 345
using namespace std;
bool pd(int year) {
if( !(year % 400)||!(year % 4)&&year%100)
return true;
return false;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("run.in" ,"r" , stdin);
freopen("run.out","w", stdout);
#endif
int ryear[MAX];
memset(ryear,0,sizeof(ryear));
int x,y,n,sum = 0;
bool kkk;
cin>>x>>y;
for(x,y; x <= y; x++) {
kkk = pd(x);
if(kkk) {
sum++;
ryear[n++] = x;
}
}
cout<<sum<<endl;
for(int step = 0; step < n; step++) {
cout<<ryear[step]<<" ";
}
return 0;
}
大佬救救QWQ
by GeYang @ 2024-10-09 13:35:03
#include<bits/stdc++.h>
#define MAX 345
using namespace std;
bool pd(int year) {
if( !(year % 400)||!(year % 4)&&year%100)
return true;
return false;
}
int main() {
#ifndef ONLINE_JUDGE
freopen("run.in" ,"r" , stdin);
freopen("run.out","w", stdout);
#endif
int ryear[MAX];
memset(ryear,0,sizeof(ryear));
int x,y,n,sum = 0;
bool kkk;
cin>>x>>y;
for(int i=x; i <= y; i++)
{
if(pd(i)) {
sum++;
ryear[n++] = i;
}
}
cout<<sum<<endl;
for(int step = 0; step < n; step++) {
cout<<ryear[step]<<" ";
}
return 0;
}
by wuhaoxuan0301 @ 2024-11-24 15:22:22
换一个函数