Magacc1’s Weblog

Just another WordPress.com weblog

Recursividad

//Serie de fibonacci con recursividad y dos variables
#include<iostream.h>
#include<conio.h>
#include<dos.h>

void func1(int n,int f,int aux);

void  main()
{
 clrscr();
 int n;
     func1(5,0,1);

 getch();
}

void func1(int n,int f,int aux)
{
 cout<<f;

 if(n>1)
 {

  func1((n-1),(f+aux),f);

 }
}

Todavía no hay comentarios »

Tu comentario

HTML-Tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>