Advertisement
cska1312

Pyramid

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