Rabu, 05 Desember 2012

Program Fibonanci dengan Array


#include <conio.h>
#include <iostream.h>
#define max 10

int fibo[max];

main(){

int i;
fibo[1]=1;
fibo[2]=1;
for (i=3;i<max;i++)
{ fibo [i]=fibo[i-2]+fibo[i-1]; }
cout<<max<<" Bilangan Fibonanci Pertama ada di : \n";
for (i=1;i<max;i++)
{ cout<<" "<<fibo[i];}

getch();}

0 komentar:

Posting Komentar