The program must first read the initialization data from standard input. Then, within an infinite loop, read the device

动态 未结 0 117
小小草
小小草 LV1 2023年9月23日 23:40 发表
The program should follow the following steps: 1. Read the initialization data from standard input, including the width and height of the building (W and H), the number of jumps allowed before the bombs go off (N), and your starting position (X0 and Y0). 2. Enter an infinite loop to continuously read device data from standard input and provide movement instructions to standard output. 3. For each device data input, first read the device code (COLDER, WARMER, SAME, or UNKNOWN) from standard input. 4. Then, read the location of the next window you should jump to (X and Y) from standard input. 5. Calculate the distance between your current position and the target window using the Pythagorean theorem: distance = sqrt((X-X0)^2 + (Y-Y0)^2). 6. If the device code is COLDER, move towards the target window by jumping half the distance towards it. If the device code is WARMER, jump the full distance towards the target window. If the device code is SAME or UNKNOWN, jump a quarter of the distance towards the target window. 7. Update your current position (X0 and Y0) after each jump. 8. Repeat steps 3-7 until you have used up all your allowed jumps (N) or you have successfully reached the target window. 9. If you reach the target window before the bombs go off, output "SUCCESS" to standard output. Otherwise, output "GAME OVER" to standard output.
收藏(0)  分享
相关标签: 智能问答
问题没解决?让AI助手帮你作答 AI助手
0个回复
  • 消灭零回复