Advertisement
Guest User

Untitled

a guest
Dec 17th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. else {
  2. if (m % 2 == 0) {
  3. int h = (n - 1)*m ;
  4. for (q = m; q; q--)
  5. cout << 1 << " " << q << endl;
  6. for (int xx = 2, yy = 1, u = 1; h; xx += u,h--) {
  7. cout << xx << " " << yy << endl;
  8. if (xx == n || (xx == 2 && yy > 1)) {
  9. u *= -1;
  10. yy++;
  11. if (yy <= m) {
  12. h--;
  13. cout << xx << " " << yy << endl;
  14. }
  15. }
  16. }
  17. }
  18. else if (n % 2 == 0) {
  19. int h = (m - 1)*n;
  20. for (q = n; q; q--)
  21. cout << q << " " << 1 << endl;
  22. for (int xx = 1, yy = 2, u = 1; h;h--, yy += u) {
  23. cout << xx << " " << yy << endl;
  24. if (yy == m || (yy == 2 && xx > 1)) {
  25. u *= -1;
  26. xx++;
  27. if (xx <= n) {
  28. h--;
  29. cout << xx << " " << yy << endl;
  30. }
  31. }
  32. }
  33. }
  34. else cout << -1;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement