Advertisement
WONGDEEM

Untitled

Jul 26th, 2019
112
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n;
  7.     cin >> n;
  8.     string row;
  9.     for (int i=0;i<n;i++) {
  10.         for (int j=0;j<n-i-1;j++) {
  11.             row.append(" ");
  12.         }
  13.         for (int k=0;k<2*i+1;k++) {
  14.             row.append("*");
  15.         }
  16.         cout << row << endl;
  17.         row = "";
  18.     }
  19.     for (int i=n-2;i>=0;i--) {
  20.         for (int j=0;j<n-i-1;j++) {
  21.             row.append(" ");
  22.         }
  23.         for (int k=0;k<2*i+1;k++) {
  24.             row.append("*");
  25.         }
  26.         cout << row << endl;
  27.         row = "";
  28.     }
  29. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement