Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n;
  8. cin >> n;
  9. int rows = 1;
  10. for (int i = 1; i <= n * n; i+=n)
  11. {
  12.  
  13. if (rows % 2 != 0)
  14. {
  15. for (int p = i; p <= i+n-1; p++)
  16. {
  17. cout << p;
  18. if (p == i+n-1)
  19. {
  20. cout << endl;
  21. rows++;
  22. }
  23. }
  24. }
  25. else
  26. {
  27. for (int q = i+n-1; q >= i; q--)
  28. {
  29. cout << q;
  30. if (q == i)
  31. {
  32. cout << endl;
  33. rows++;
  34. }
  35. }
  36. }
  37. }
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement