fahimkamal63

Dimonds Printing

Jul 18th, 2019
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. //  Dimonds Printing
  2. //  Date : 15.07.19
  3. #include<iostream>
  4. using namespace std;
  5.  
  6. int main(){
  7.     int n; cin >> n;
  8.     int k = 3;
  9.     for(int i = 0; i < n; i++){
  10.         for(int j = 0; j < n-i; j++){
  11.             cout << ' ';
  12.         }
  13.         if(i == 0) { cout << '*'; }
  14.         else{
  15.             for(int j = 0; j < k; j++){
  16.                 cout << '*';
  17.             }
  18.             k += 2;
  19.         }
  20.         cout << endl;
  21.     }
  22.     k -= 4;
  23.     for(int i = 0; i < n-1; i++){
  24.         for(int j = -1; j <= i; j++){
  25.             cout << ' ';
  26.         }
  27.         if(i == n-2) { cout << '*'; }
  28.         else{
  29.             for(int j = 0; j < k; j++){
  30.                 cout << '*';
  31.             }
  32.             k -= 2;
  33.         }
  34.         cout << endl;
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment