fork download
  1. int main()
  2. {
  3. int lightX; // the X position of the light of power
  4. int lightY; // the Y position of the light of power
  5. int initialTX; // Thor's starting X position
  6. int initialTY; // Thor's starting Y position
  7. scanf("%d%d%d%d", &lightX, &lightY, &initialTX, &initialTY);
  8. int thorX=initialTX;
  9. int thorY=initialTY;
  10. // game loop
  11. while (1) {
  12. //int remainingTurns; // The remaining amount of turns Thor can move. Do not remove this line.
  13. //scanf("%d", &remainingTurns);
  14. char directionX[]="";
  15. char directionY[]="";
  16. if(thorX>lightX)
  17. {
  18. directionX[0]="W";
  19. thorX--;
  20. }
  21. else if(thorX<lightX)
  22. {
  23. directionX[0]="E";
  24. thorX++;
  25. }
  26. if(thorY>lightY)
  27. {
  28. directionY[0]="N";
  29. thorY--;
  30. }
  31. else if(thorY<lightY)
  32. {
  33. directionY[0]="S";
  34. thorY++;
  35. }
  36. // strcat(directionX,directionY);
  37.  
  38.  
  39. // Write an action using printf(). DON'T FORGET THE TRAILING \n
  40. // To debug: fprintf(stderr, "Debug messages...\n");
  41.  
  42. printf("%s\n",directionX); // A single line providing the move to be made: N NE E SE S SW W or NW
  43. }
  44.  
  45. return 0;
  46. }
Runtime error #stdin #stdout 0s 2164KB
stdin
31 4
5 4
stdout
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�
�