Advertisement
Guest User

Untitled

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