Advertisement
syartina_elfarika

My source code

Nov 21st, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 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.     for (y=1;y<=b-1;y++){
  13.        
  14.         for (z=y;z<=b;z++) {
  15.             cout<<"  ";
  16.         }
  17.         for (x=1;x<=y-1;x++){
  18.             if (x==1)
  19.                 cout<<" *";
  20.             else
  21.                 cout<<"  ";
  22.         }
  23.         for (x=y;x>=1;x--) {
  24.             if (x==1)
  25.                 cout<<" *";
  26.             else
  27.                 cout<<"  ";
  28.         }
  29.         cout<<endl;  
  30.     }
  31.    
  32.     for (y=b;y>=1;y--){
  33.        
  34.         for (z=y;z<=b;z++) {
  35.             cout<<"  ";
  36.         }
  37.         for (x=1;x<=y-1;x++){
  38.             if (x==1)
  39.                 cout<<" *";
  40.             else
  41.                 cout<<"  ";
  42.         }
  43.         for (x=y;x>=1;x--) {
  44.             if (x==1 or x==b)
  45.                 cout<<" *";
  46.             else
  47.                 cout<<"  ";
  48.         }
  49.         cout<<endl;  
  50.     }
  51.        
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement