Advertisement
Guest User

asd

a guest
Jul 29th, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. /**
  9. * Auto-generated code below aims at helping you parse
  10. * the standard input according to the problem statement.
  11. * ---
  12. * Hint: You can use the debug stream to print initialTX and initialTY, if Thor seems not follow your orders.
  13. **/
  14. int main()
  15. {
  16. int lightX; // the X position of the light of power
  17. int lightY; // the Y position of the light of power
  18. int initialTX; // Thor's starting X position
  19. int initialTY; // Thor's starting Y position
  20. cin >> lightX >> lightY >> initialTX >> initialTY; cin.ignore();
  21.  
  22. string dir = "";
  23.  
  24. // game loop
  25. while (1) {
  26. int remainingTurns;
  27. cin >> remainingTurns; cin.ignore();
  28.  
  29. if(lightY>initialTY)
  30. { dir="S";
  31. initialTY++;
  32. }
  33. else if(lightY<initialTY)
  34. { dir="N";
  35. initialTY--;
  36. }
  37. else
  38. { dir=""; }
  39.  
  40. if(lightX>initialTX)
  41. { dir+="E";
  42. initialTX++;
  43. }
  44. else if(lightX<initialTX)
  45. { dir+="W";
  46. initialTX--;
  47. }
  48.  
  49. // Write an action using cout. DON'T FORGET THE "<< endl"
  50. // To debug: cerr << "Debug messages..." << endl;
  51.  
  52. cout << dir << endl; // A single line providing the move to be made: N NE E SE S SW W or NW
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement