Diana Molina

blog personal WordPress.com weblog

RESOLUCION DE LA SERIE FIBONACI

SOLUCIÒN DE LA SERIE FIBONACI

PRIMERA SOLUCION

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

//Declaracion de prototipos
void fun1(int n, int f,int aux);

//FUNCION PRINCIPAL
void main()
{
clrscr();

fun1(5,0,1);
getch();
}

//Aplicando recursividad
void fun1(int n, int f,int aux)
{
cout<<f<<”\n”;
if(n>1)
}

Segunda solución
//DECLARACION DE LIBRERIAS
#include<iostream.h>
#include<conio.h>

//Declaracion de prototipos
void fun1(int n);

//VARIABLES GLOBALES
int f=0,b=1,c=1,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();
}

//Aplicando recursividad

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);
}

}

Tercera solución

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

//Declaracion de prototipos
void fun1(int n,int b, int c, int f);

//VARIABLES GLOBALES
//int fi=5,co=20;

//FUNCION PRINCIPAL
void main()
{
clrscr();

fun1(5,1,1,0);
getch();
}

//Aplicando recursividad
void fun1(int n,int b, int c, int f)
{
cout<<f<<”\n”;
if(n>1)
{
fun1((n-1),c,f,(f+c));
}

}

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>