天天看点

Ackerman函数A(m, n)的递归和循环实现

这种函数还是递归简单- -

#include <stdio.h>

int arc(int m, int n);
int main(void) {
    int m, n;
    printf("请输入m,n : ");
    scanf("%d, %d", &m, &n);
    printf("%d\n",arc(m, n));
    return 0;
}
int arc(int m, int n){
    if(m ==0){
        return n+1;
    }
    else {if(n == 0){
        return arc(m-1, 1);
    }
    else{
        return arc(m-1, arc(m, n-1));
    }
    }
}
           

循环实现暂缺