fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7.  
  8. int cnt=1;
  9. for(int i=1; i<=n; ++i){
  10. if(i&1){
  11. for(int j=1; j<=i; ++j){
  12. cout << cnt++ << "*";
  13. }
  14. cout << endl;
  15. }
  16. else{
  17. for(int j=1; j<=i; ++j){
  18. cout << (cnt+(i-j+1)) << "*";
  19. cnt++;
  20. }
  21. cout << endl;
  22. }
  23. }
  24.  
  25. return 0;
  26. }
Success #stdin #stdout 0s 15232KB
stdin
4
stdout
1*
4*4*
4*5*6*
11*11*11*11*