fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main() {
  6. int n;
  7. cin >> n;
  8. for (int i=1; i<=n; i++) {
  9. for (int j=0; j<n-i; j++) {
  10. cout << ' ';
  11. }
  12. for (int j=0; j<1+2*(i-1); j++) {
  13. cout << '*';
  14. }
  15. cout << endl;
  16. }
  17. return 0;
  18. }
Success #stdin #stdout 0s 4300KB
stdin
4
stdout
   *
  ***
 *****
*******