关于```bug2```,如果使用的是windows系统,可以尝试打开<windows.h>,并在main函数的开头加上
```cpp
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (hOut == INVALID_HANDLE_VALUE)
return GetLastError();
DWORD dwMode = 0;
if (!GetConsoleMode(hOut, &dwMode))
return GetLastError();
dwMode |= 0x0004;
if (!SetConsoleMode(hOut, dwMode))
return GetLastError();
```
by lcy666666 @ 2024-04-03 15:45:48
关于```bug3```,你的确没有写随机地图的代码。。。
by lcy666666 @ 2024-04-03 15:48:53
@[2345A](/user/565070)
by lcy666666 @ 2024-04-03 15:49:07
@[lcy666666](/user/491219) 谢谢
by 2345A @ 2024-04-03 15:53:08
@[2345A](/user/565070) 关于```bug1```,```clock```的计时随着程序而开始,因此这行代码的含义是等待程序运行到大于等于第5秒,故无效,可以使用如下代码实现等待5秒
```cpp
for(int st = clock(); (clock() - st) / CLOCKS_PER_SEC <= 5.00;);
```
求关
by lcy666666 @ 2024-04-03 16:00:08
@[lcy666666](/user/491219) Sleep(5000);
by BGM114514 @ 2024-04-03 16:01:49
另,还有一个bug,只判断了食物与子弹之和为10,而没有判断食物不得为负数
by lcy666666 @ 2024-04-03 16:02:31
@[lcy666666](/user/491219) 关注了
by 2345A @ 2024-04-03 16:32:18
@[2345A](/user/565070) 感谢
by lcy666666 @ 2024-04-03 16:35:15
@[2345A](/user/565070) @[2345A](/user/565070) main函数前加:
```
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
if (hOut == INVALID_HANDLE_VALUE)
return GetLastError();
DWORD dwMode = 0;
if (!GetConsoleMode(hOut, &dwMode))
return GetLastError();
dwMode |= 0x0004;
if (!SetConsoleMode(hOut, dwMode))
return GetLastError();
```
by dongrunxuan @ 2024-04-03 16:37:00