Advertisement
khisby

diamond with line in middle

Nov 25th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main(){
  4.     cout<<"Masukkan angka :  ";
  5.  
  6.     int size;
  7.     cin>>size;
  8.  
  9.     int z=1;
  10.     for ( int i=0; i<=size-2; i++){
  11.         for (int j=size; j>i; j--){
  12.           cout<<" ";
  13.         }
  14.  
  15.         cout<<"*";
  16.  
  17.         if (i>0){
  18.           for ( int k=1; k<=z; k++){
  19.             cout<<" ";
  20.           }
  21.           z+=2;
  22.           cout<<"*";
  23.         }
  24.         cout<<endl;
  25.     }
  26.  
  27.     for(int a=0; a<size; a++){
  28.         cout << " *";
  29.     }
  30.     cout << endl;
  31.  
  32.     z-=4;
  33.  
  34.     for (int i=0; i<=size-2; i++){
  35.         for (int j=0; j<=i+1; j++){
  36.           cout<<" ";
  37.         }
  38.  
  39.         cout<<"*";
  40.  
  41.         for (int k=0; k<=z+1; k++){
  42.           cout<<" ";
  43.         }
  44.         z-=2;
  45.  
  46.         if (i!=size-2){
  47.           cout<<"*";
  48.         }
  49.         cout<<endl;
  50.     }
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement