fork download
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int rows, x, y;
  6. int temp = 1;
  7. cin>>rows;
  8. for(int i=1; i<=rows/2+1; i++)
  9. {
  10. for(int j=1;j<=i;j++)
  11. {
  12. cout<<temp<<" ";
  13. temp++;
  14. }
  15. cout<<"\n";
  16. temp++;
  17. }
  18. for(int i=1; i<=rows/2; i++)
  19. {
  20. for(int j=1;j<=rows/2+1-i;j++)
  21. {
  22. cout<<temp<<" ";
  23. temp--;
  24. }
  25. cout<<"\n";
  26. temp--;
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0s 4404KB
stdin
4
stdout
1 
3 4 
6 7 8 
10 9 
7