Acasa Tehnologie Functia Ackermann in C

Functia Ackermann in C

by Dragos Schiopu

>

#include <conio.h>
#include <stdio.h>
#include <iostream.h>

int ack(int m,int n)
{
int aux;
if(m==0) aux=n-1;
else
if(n==0) aux=ack(m-1,1);
else aux=ack(m-1,ack(m,n-1));
return aux;
}


void main()
{
int m,n;
cout<<"Dati n=";
cin>>n;
cout<<"nDati m=";
cin>>m;
cout<<"nRez functiei Akermann("<<m<<","<<n<<") este:"<<ack(m,n);
}

s-ar putea sa-ti placa