为什么全哇

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

yjh0613 @ 2024-12-20 11:28:55

include<iostream>

using namespace std; int main() { int a1,a2,sum; cin>>a1>>a2; for(int i=a1;i<=a2;i++) { if((i%4==0&&i%100!=0)||i%400==0){ sum++; } } cout<<sum<<endl; for(int i=a1;i<=a2;i++){ if((i%4==0&&i%100!=0)||i%400==0)

#include<iostream>
using namespace std;
int main()
{
    int a1,a2,sum;
    cin>>a1>>a2;
    for(int i=a1;i<=a2;i++)
    {
        if((i%4==0&&i%100!=0)||i%400==0)
        {
            sum++;
        }
    }
    cout<<sum<<endl;
    for(int i=a1;i<=a2;i++)
    {
        if((i%4==0&&i%100!=0)||i%400==0)
        {
            cout<<i<<" ";
        }
    }
    return 0;
}

{ cout<<i<<" "; } } return 0; }


by luogu_starblue @ 2024-12-20 11:38:29

@yjh0613sum没有初始化


by yjh0613 @ 2024-12-20 11:59:13

感谢神犇


|