fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int n;
  7. cin >> n;
  8.  
  9. for (int i = 1; i <= n; i++)
  10. {
  11. // طباعة المسافات (n - i)
  12. for (int s = 1; s <= n - i; s++)
  13. {
  14. cout << " ";
  15. }
  16.  
  17. // طباعة النجوم (2 * i - 1)
  18. for (int j = 1; j <= 2 * i - 1; j++)
  19. {
  20. cout << "*";
  21. }
  22.  
  23. cout << endl;
  24. }
  25.  
  26. }
Success #stdin #stdout 0.01s 5288KB
stdin
4
stdout
   *
  ***
 *****
*******