Nina__happy @ 2024-07-28 16:44:33
无语x10000
佳银们,今日新无语。
为啥不对QAQ
以下是代码:
/```#include<bits/stdc++.h>
using namespace std;
int minn,maxn,num=0;
bool runnian(int i){
if(i%10==0&&i%100/10==0){
if(i%400==0){
return 1;
}
return 0;
}
else{
if(i%4==0){
return 1;
}
return 0;
}
}
int main()
{
cin>>minn>>maxn;
int nian[maxn-minn+1];
for(int i=minn;i<=maxn;i++){
if(runnian(i)){
num++;
nian[num]+=i;
}
}
cout<<num<<endl;
for(int i=0;i<=num;i++){
cout<<nian[i]<<" ";
}
return 0;
}```\
by ly147146143 @ 2024-07-28 16:55:43
@Nina__happy 输出从1开始,避免多输出。
你试试把nian[num]+=i改为nian[num]=i; (^▽^)
by cjhhh @ 2024-07-28 16:58:49
#include<bits/stdc++.h>
using namespace std;
int minn,maxn,num=0;
bool runnian(int i){
if(i%100==0){
if(i%400==0){
return 1;
}
return 0;
}
else{
if(i%4==0){
return 1;
}
return 0;
}
}
int main()
{
cin>>minn>>maxn;
int nian[maxn-minn+1];
for(int i=minn;i<=maxn;i++){
if(runnian(i)){
num++;
nian[num]=i;
}
}
cout<<num<<endl;
for(int i=1;i<=num;i++){
cout<<nian[i]<<" ";
}
return 0;
}
@Nina__happy
by Nina__happy @ 2024-07-28 17:04:22
@ly147146143 @cjhhh 嗯嗯,感谢两位大佬,已关,谢谢
by Nina__happy @ 2024-07-28 17:05:52
已AC,结帖
by zhoumurui @ 2024-07-28 19:13:40
@Nina__happy 希望更丰富的展现?使用 Markdown。
by zhoumurui @ 2024-07-28 19:14:15
没看到结贴就发了信息,结果现在删不掉了啊喂
by Nina__happy @ 2024-07-29 19:54:48
@zhoumurui 没关系的哦
by Nina__happy @ 2024-07-29 19:55:34
@zhoumurui 我也会即时查看滴
by Nina__happy @ 2024-07-29 19:57:19
@zhoumurui 已关注(提了意的都会关滴)
by wangmuze @ 2024-08-23 10:43:35
nian[num]+=i->nian[num]=i; (^▽^)