Kamis, 31 Maret 2016

PEMROGRAMAN FUNGSI DERET FIBONACCI ( KASUS 5.6 )

1.C++ :
#include <iostream>
#include <string>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
void fibonacci(int n, int f1, int f2, int x){
 int f3;
 if(x>(n-2))
 {
 }
 else
 {
  f3=f1+f2;
  cout<<f3<<", ";
  f1=f2;
  f2=f3;
  x=x+1;
  fibonacci(n,f1,f2,x);
 }
}
int main(int argc, char** argv) {
 int f1;
 int n;
 int f2;
 int x;
 cout<<"Masukkan suku ke-n : ";
 cin>>n;
 cout<<"fibonacci suku ke-"<<n<<endl;
 x=1;
 f1=0;
 f2=1;
 cout<<f1<<", "<<f2<<", ";
 fibonacci(n,f1,f2,x);
 return 0;
}

2.Raptor :
luvne.com ayeey.com cicicookies.com mbepp.com kumpulanrumusnya.com.com tipscantiknya.com

0 komentar:

Posting Komentar