Advertisement
fiqriachmada

BilanganFibonacciMery

Nov 27th, 2018
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3.  
  4. using namespace std;
  5. int y,n;char in;
  6. bool state=true;
  7.  
  8. int main()
  9. {
  10.     while(state){
  11.     int x,y,i,j,k;
  12.     int a=0,b=1,c;
  13.  
  14.     cout<<"\n X = ";
  15.     cin>>x;
  16.     cout<<" Y = ";
  17.     cin>>y;
  18.  
  19.     for(i=0; i<=y-1; i++){
  20.         for(j=0; j<=((2*y)-(2*i)); j++){
  21.             cout<< " " ;}
  22.         for(k=0; k<=i; k++)
  23.         {
  24.             c=a+b; b=a; a=c;
  25.             if(i>=x-1)
  26.             {
  27.                 cout<<" ";
  28.                 cout<<" "<<c%10;
  29.                 cout<<" ";
  30.             }
  31.         }
  32.         cout<<endl;
  33.  
  34.        }
  35.        cout << "\n\n" << "Ulang lagi ?(y/n) -> "; cin >> in;
  36.             if(in == 'n' || in=='N'){
  37.             cout << "Terima Kasih :)" << endl;
  38.             state = false;}
  39.             else if(in == 'y' || in=='Y'){
  40.             cout << "Ok ulang lagi\n" << endl;}
  41.  
  42.  
  43.  }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement