Advertisement
syartina_elfarika

Untitled

Nov 21st, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.19 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. main (){
  4.    
  5.     int b,x,y,z;
  6.    
  7.     cout<<"Masukkan Batas : ";
  8.     cin>>b;
  9.     cout<<endl;
  10.    
  11.    
  12.     y=1;
  13.     while (y<=b-1){
  14.         z=y;
  15.         while (z<=b)
  16.         {
  17.          cout<<"  ";
  18.          z++;  
  19.         }
  20.         x=1;
  21.         while (x<=y-1)
  22.         {
  23.             if (x==1)
  24.                 cout<<" *";
  25.             else
  26.                 cout<<"  ";
  27.             x++;
  28.         }
  29.         x=y;
  30.         while (x>=1)
  31.         {
  32.             if (x==1)
  33.                 cout<<" *";
  34.             else
  35.                 cout<<"  ";
  36.             x--;  
  37.         }
  38.         y++;
  39.         cout<<endl;
  40.     }
  41.    
  42.     y=b;
  43.     while (y>=1) {
  44.         z=y;
  45.         while (z<=b)
  46.         {
  47.             cout<<"  ";
  48.             z++;  
  49.         }
  50.         x=1;
  51.         while (x<=y-1)
  52.         {
  53.             if (x==1)
  54.                 cout<<" *";
  55.             else
  56.                 cout<<"  ";
  57.             x++;
  58.         }
  59.         x=y;
  60.         while (x>=1)
  61.         {
  62.             if (x==1 or x==b)
  63.                 cout<<" *";
  64.             else
  65.                 cout<<"  ";
  66.             x--;
  67.         }
  68.      y--;
  69.         cout<<endl;
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement