Advertisement
Spocoman

06. Rhombus of Stars

Sep 13th, 2023
1,145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int n;
  7.     cin >> n;
  8.  
  9.     for (int i = 1; i <= n; i++) {
  10.         for (int j = 0; j < n - i; j++) {
  11.             cout << " ";
  12.         }
  13.         for (int k = 0; k < i; k++) {
  14.             cout << "* ";
  15.         }
  16.         cout << endl;
  17.     }
  18.  
  19.     for (int i = n - 1; i > 0; i--) {
  20.         for (int j = n - i; j > 0; j--) {
  21.             cout << " ";
  22.         }
  23.         for (int k = 0; k < i; k++) {
  24.             cout << "* ";
  25.         }
  26.         cout << endl;
  27.     }
  28.  
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement