Advertisement
gojali

Coba Aja Dulu.cpp

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