递归问题总是re,求助

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

Zsm061018 @ 2024-11-15 15:28:24


#include<bits/stdc++.h>
using namespace std;
int mark=0;
int leap(int x,int y)
{
    if(x==y) return mark;
    if(x%400==0||x%4==0&&x%100!=0)
    {
        mark++;
    }
    leap(++x,y);
}
void year(int m,int n)
{
    if(m==n) return;
    if(m%400==0||m%4==0&&m%100!=0)
    {
        cout<<m<<" ";
    }
    year(++m,n);
}
int main()
{
    int a,b;
    cin>>a>>b;
    cout<<leap(a,b)<<"\n";
    year(a,b);
    return 0;
}

by zzz13579zzz @ 2024-11-15 15:36:36

leap改成void


|