Advertisement
Andrey_ZoZ

Untitled

Nov 6th, 2020
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. void main()
  4. {
  5. int n, m;
  6. std::cin >> n >> m;
  7. int upMax{ 1 }, downMax{ n-1 }, leftMax{ 0 }, rightMax{ m-1 };
  8. int count{ 0 };
  9. int startX{ 0 }, startY{ 0 };
  10. bool check = true;
  11. while (check==true)
  12. {
  13. check = false;
  14. std::cout << "RUN RIGHT\n";
  15. while (startX < rightMax)
  16. {
  17. std::cout << startX << " " << startY << " | " << count<<"\n";
  18. ++startX;
  19. check = true;
  20. }
  21. std::cout << startX << " " << startY << " | " << count << "\n";
  22. if (check == false) { break; }
  23. check = false;
  24. --rightMax;
  25. ++count;
  26. std::cout << "RUN DOWN\n";
  27. while (startY < downMax)
  28. {
  29. std::cout << startX << " " << startY << " | " << count << "\n";
  30. ++startY;
  31. check = true;
  32. }
  33. std::cout << startX << " " << startY << " | " << count << "\n";
  34. if (check == false) { break; }
  35. check = false;
  36. --downMax;
  37. ++count;
  38. std::cout << "RUN LEFT\n";
  39. while (startX > leftMax)
  40. {
  41. std::cout << startX << " " << startY << " | " << count << "\n";
  42. --startX;
  43. check = true;
  44. }
  45. std::cout << startX << " " << startY << " | " << count << "\n";
  46. if (check == false) { break; }
  47. check = false;
  48. ++leftMax;
  49. ++count;
  50. std::cout << "RUN UP\n";
  51. while (startY > upMax)
  52. {
  53. std::cout << startX << " " << startY << " | " << count << "\n";
  54. --startY;
  55. check = true;
  56. }
  57. std::cout << startX << " " << startY << " | " << count << "\n";
  58. if (check == false) { break; }
  59. ++upMax;
  60. ++count;
  61. }
  62. std::cout << count-1;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement