?????????????

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

S_mz @ 2024-07-17 15:19:37

#include<bits/stdc++.h> 
using namespace std;
bool isr(int a){
    if(a%100!=0&&a%4==0||a%400==0){
        return true;
    }
    return false;
}         
int main(){
    int a,b,sum;
    cin>>a>>b;
    for(int i=a;i<=b;i++){
        if(isr(i)){
            sum++;
        }
    }
    cout<<sum<<"\n";
    for(int i=a;i<=b;i++){
        if(isr(i)){
            cout<<i<<' ';
        }
    }
    return 0;
}

by PhirainEX @ 2024-07-17 15:24:08

int a,b,sum=0;

在main函数里的变量需要手动设为0


|