Power of Thor 雷神托尔的能量
The Goal
Your program must allow Thor to reach the light of power.
//你的程序必须能让Thor到达能量之光
Rules
Thor moves on a map which is 40 wide by 18 high. Note that the coordinates (X and Y) start at the top left! This means the most top left cell has the coordinates “X=0,Y=0” and the most bottom right one has the coordinates “X=39,Y=17”.
//Thor在一个40*18的地图上移动。注意左上方建立的坐标系,左上角为(0,0)和右下角(39,17),Thor的位置超出界限(X<0,X>39,Y<0,Y>17)都算输
//coordinate: 坐标
Once the program starts you are given:
//在任务的开始,你会得到:
·the variable lightX: the X position of the light of power that Thor must reach.
·the variable lightY: the Y position of the light of power that Thor must reach.
·the variable initialTX: the starting X position of Thor. //Thor开始的位置
·the variable initialTY: the starting Y position of Thor.
Game Input
//游戏输入
The program must first read the initialization(初始化) data from the standard input, then, in an infinite(无限) loop, provides on the standard output the instructions(指令) to move Thor.
Initialization input
//初始化输入
Line 1: 4 integers(整数) lightX lightY initialTX initialTY.
(lightX, lightY) indicates(表明) the position of the light.
(initialTX, initialTY) indicates the initial position of Thor.
Input for a game round
//游戏每回合输入(游戏显示)
Line 1: the number of remaining moves for Thor to reach the light of power: remainingTurns. You can ignore this data but you must read it.
Output for a game round
//游戏每回合输出(游戏需要输出的指令)
A single line providing the move to be made: N NE E SE S SW W or NW
原程序
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
* ---
* Hint: You can use the debug stream to print initialTX and initialTY, if Thor seems not follow your orders.
* 提示:当Thor没有按照你预想的方式来移动时