Advertisement
Lexolordan

number 1

May 19th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <math.h>
  4.  
  5. using namespace std;
  6.  
  7. struct point
  8. {
  9.     int x, y;
  10. };
  11.  
  12. int main()
  13. {
  14.     point Lev, Gien;
  15.     int k;
  16.     Lev.y = 1;
  17.     cin >> k >> Lev.x >> Gien.x >> Gien.y;
  18.  
  19.     while (Lev.y != k)
  20.     {
  21.         if (((Gien.x != Lev.x)||(Gien.y != Lev.y + 1))&&(abs(Lev.x - Lev.y - 1) != abs(Gien.x - Gien.y))&&(Lev.x + Lev.y + 1 != Gien.x + Gien.y))
  22.         {
  23.             ++Lev.y;
  24.             cout << Lev.y << " " << Lev.x << endl;
  25.             cout.flush();
  26.         }
  27.         else if (Lev.x != 1)
  28.         {
  29.             --Lev.x;
  30.             ++Lev.y;
  31.             cout << Lev.y << " " << Lev.x << endl;
  32.             cout.flush();
  33.         }
  34.         else
  35.         {
  36.             ++Lev.x;
  37.             ++Lev.y;
  38.             cout << Lev.y << " " << Lev.x << endl;
  39.             cout.flush();
  40.         }
  41.  
  42.         if (Lev.y != k)
  43.         {
  44.             cin >> Gien.x >> Gien.y;
  45.         }
  46.     }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement