alexander masache
Hola soy de la carrera de informáticaArchivos para Abril, 2008
Fibonacci la tercera forma
//DECLARACION DE LIBRERIAS
#include<iostream.h>
#include<conio.h>
#include<dos.h>
//Declaracion de prototipos
void fun1(int n);
//VARIABLES GLOBALES
int b=1,c=1,f=0,fi=5,co=20;
//FUNCION PRINCIPAL
void main()
{
clrscr();
int a;
cout<<” > >>>*INGRESE LA CANTIDAD DE NUMEROS …. \n”;
cout<<” >>>>* DE LA SERIE FIBONACI QUE DESEE …. \t”;
cin>>a;
cout<<”\n\n\n”;
fun1(a);
getch();
}
//LLAMAR UNA FUNCION DENTRO DENTRO DE OTRA FUNCION
void fun1(int n)
{
gotoxy(co,fi);
cout<<f<<”\n”;
fi=fi+3;
b=c;
c=f;
f=b+c;
if(n>1)
{
n–;
fun1(n);
}
}
OTRA FORMA DE FIBONACCI POR RECURSIVIDAD
//DECLARACION DE LIBRERIAS
#include<iostream.h>
#include<conio.h>
#include<dos.h>
//Declaracion de prototipos
void fun2(int n,int f,int aux );
void main()
{
clrscr();
int a;
cout<<” > >>>*INGRESE LA CANTIDAD DE NUMEROS …. \n”;
cout<<” >>>>* DE LA SERIE FIBONACCI QUE DESEE …. \t”;
cin>>a;
cout<<”\n\n\n”;
fun2(a,0,1);
getch();
}
//LLAMAR UNA FUNCION DENTRO DENTRO DE OTRA FUNCION
void fun2(int n,int f,int aux)
{
cout<<f<<”\n\n”;
if(n>1)
{
fun2((n-1),(f+aux),(f));
}
}
RECURSIVIDAD
FIBONACI
//DECLARACION DE LIBRERIAS
#include<iostream.h>
#include<conio.h>
#include<dos.h>
//Declaracion de prototipos
void fun1(int n,int b,int c,int f);
void main()
{
clrscr();
int a;
cout<<” > >>>*INGRESE LA CANTIDAD DE NUMEROS …. \n”;
cout<<” >>>>* DE LA SERIE FIBONACI QUE DESEE …. \t”;
cin>>a;
cout<<”\n\n\n”;
fun1(a,1,1,0);
getch();
}
//LLAMAR UNA FUNCION DENTRO DENTRO DE OTRA FUNCION
void fun1(int n,int b,int c,int f)
{
cout<<f<<”\n\n”;
if(n>1)
{
fun1((n-1),c,f,(f+c));
}
}