Advertisement
Guest User

Untitled

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