斐波那契数列(指针传递)

#include <bits/stdc++.h>
using namespace std;

int NUM ( int *a)
{
    int b=*a-1;
    int c=*a-2;
    if(*a<=2) return 1;
    else return NUM(&b) + NUM (&c);
}
int main()
{
    int NUMx , NUMy;
    cin >> NUMx ;
    cout << NUM (&NUMx);
    return 0;
}

 

posted @ 2023-10-29 09:44  hanxuyao  阅读(34)  评论(0)    收藏  举报