Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 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. int thorX;
  21. int thorY;
  22. thorX = initialTX;
  23. thorY = initialTY;
  24. cin >> lightX >> lightY >> initialTX >> initialTY; cin.ignore();
  25.  
  26. // game loop
  27. while (1) {
  28. int remainingTurns; // The remaining amount of turns Thor can move. Do not remove this line.
  29. cin >> remainingTurns; cin.ignore();
  30. char directionX;
  31. char directionY;
  32. if (thorY > lightY)
  33. {
  34. directionY = "N";
  35. thorY = thorY--;
  36.  
  37. }
  38. else if (thorY < lightY)
  39. {
  40. directionY = "S";
  41. thorY++;
  42. }
  43. if (thorX > lightX)
  44. {
  45. directionX = "W";
  46. thorX = thorX--;
  47. }
  48. else if (thorX < lightX)
  49.  
  50. {
  51. directionX = "E";
  52. thorX = thorX++;
  53. }
  54.  
  55. // Write an action using cout. DON'T FORGET THE "<< endl"
  56. // To debug: cerr << "Debug messages..." << endl;
  57.  
  58. cout << directionY << directionX << endl; // A single line providing the move to be made: N NE E SE S SW W or NW
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement