过了样例,可是零分?

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

sshhgggddsbf @ 2024-03-12 22:14:14

#include<bits/stdc++.h>
using namespace std;
bool ru(int a){
    bool r=false;
        if((a%4==0 && a%100!=0 )|| a%400==0){
            r=true;
        }
    return r;

}
int main(){
    int a,b,cnt;
    cin>>a>>b;
    for(int i=a;i<=b;i++){
        if(ru((i))){
            cnt++;
        }
    }

    cout<<cnt<<endl;
    for(int i=a;i<=b;i++){
        if(ru((i))){
            cout<<i<<" ";
        }
    }
    cout<<endl;
    return 0;
}

by Lizichen_licis @ 2024-03-24 10:11:58

cnt初始化一下 @sshhgggddsbf


by Lizichen_licis @ 2024-03-24 10:12:30

你就加一句cnt=0,在cin>>a>>b;之前


by Lizichen_licis @ 2024-03-24 10:12:40

@sshhgggddsbf


by sshhgggddsbf @ 2024-03-24 18:03:34

忘了,谢谢谢谢


by ChasonWang @ 2024-06-18 19:32:18

@sshhgggddsbf 初始化cnt


|