Wednesday, 4 December 2013

Program Deret Fibonaci dan Tribonaci (DEV C++)

PROGRAM DEV C++

#include<iostream>
#include <cstdlib>
using namespace std;
int main()

{system ("color b");
int menu;
cout<<"\t\t\t Selamat Datang di Program Kami\n";
cout<<"\t ----------Program Deret Fibonaci dan Tribonaci----------\n";
cout<<"\t\n       =========== Oleh Kelompok 8 Teknik Informatika C ===========\n";
cout<<"\t    Agri Kuswandani        >>    5130411162"<<endl;

cout<<"\n\n Pilih Jenis Deret :\n";
cout<<"\n1.Deret Fibonaci \n";
cout<<"\n2.Deret Tribonaci \n";
cout<<"\nSilahkan Tentukan Jenis deret (1-2) : ";cin>>menu;
switch (menu)
{{case 1:
int x,y,z,a,jml;
cout<<"\n \n \n \t  _______________ Program Deret Fibonaci _____________\n" ;
cout<<"\n Masukan Jumlah Deret : ";cin>>jml;
cout<<"\n Masukan Deret 1 : ";cin>>x;
cout<<"\n Masukan Deret 2 : ";cin>>y;
cout<<"\n Deret Fibonaci : ";
cout<<x<<" ";
cout<<y<<" ";
for (a=1;a<=jml-2;a++)
{
z=x+y;
cout<<z<<" ";
x=y;
y=z;
}
}


break;

case 2:
    {
int v,x,y,z,a,jml;
cout<<"\n \n \n \t  _______________ Program Deret Tribonaci_____________\n \n" ;
cout<<"\n Masukan Jumlah Deret : ";cin>>jml;
cout<<"\n Masukan Deret 1 : ";cin>>x;
cout<<"\n Masukan Deret 2 : ";cin>>y;
cout<<"\n Masukan Deret 3 : ";cin>>v;
cout<<"\n Deret tribonaci : ";
cout<<x<<" ";
cout<<y<<" ";
cout<<v<<" ";
for (a=1;a<=jml-3;a++)
{
z=x+y+v;
cout<<z<<" ";
v=x;
x=y;
y=z;
}

}

}
char LG;
cout<<"\n \n Apakah anda ingin mengulang kembali program [ Y/T ] ?";cin>>LG;
if (LG=='Y' || LG=='y')main();
else if (LG=='T' || LG=='t') goto x;
x:
cout<<"Terima Kasih \n";
cout<<"see you";  

}

No comments:

Post a Comment