请帮我看下第一个代码和第二个有什么不同,输出不一样
#include "iostream"
#include "queue"
using namespace std;
char map[32][32][32];
int bookmap1[32][32][32];
int next1[6][3] = { {0,1,0},{0,-1,0},{0,0,1},{0,0,-1},{1,0,0},{-1,0,0} };
int l, r, c;
int temp = 0;
struct point {
int z;
int x;
int y;
int step;
};
int main() {
queue<point> q;
cin >> l >> r >> c;
while (1) {
if (l == 0 && r == 0 && c == 0)break;
for (int i = 0; i < l; i++, temp++) {
{
for (int j = 0; j < r; j++)
for (int z = 0; z < c; z++)
{
cin >> map[temp][j][z];
if (map[temp][j][z] == 'S')
{
q.push({ temp,j,z,0 });
map[temp][j][z] = '#';
}
}
}
}
while (!q.empty()) {
point t = q.front();
q.pop();
for (int i = 0; i < 6; i++) {
int tz = t.x + next1[i][0];
int tx = t.y + next1[i][1];
int ty = t.z + next1[i][2];
if (tz < 0 || tz >= l || tx < 0 || tx >= r || ty < 0 || ty >= c || map[tz][tx][ty] == '#' || bookmap1[tx][ty][tz] == 1)continue;
if (map[tz][tx][ty] == '.') {
q.push(point{ tz,tx,ty,t.step + 1 });
bookmap1[tz][tx][ty] = 1;
break;
}
if (map[tz][tx][ty] == 'E')
{
printf("Escaped in %d minute(s).\n", t.step + 1);
while (!q.empty()) q.pop(); // 4. 退出循环
break;
}
}
}
cout << "111";
cin >> l >> r >> c;
}
return 0;
}

#include <iostream>
#include <queue>
using namespace std;
char map[32][32][32];
int bookmap1[32][32][32];
int next1[6][3] = { {0,1,0},{0,-1,0},{0,0,1},{0,0,-1},{1,0,0},{-1,0,0} };
int l, r, c;
int temp = 0;
struct point {
int z;
int x;
int y;
int step;
};
int main() {
queue<point> q;
cin >> l >> r >> c;
while (l != 0 && r != 0 && c != 0) { // 1. 修改终止条件
for (int i = 0; i < l; i++, temp++) {
for (int j = 0; j < r; j++) {
for (int z = 0; z < c; z++) {
cin >> map[temp][j][z];
if (map[temp][j][z] == 'S') {
q.push({ temp, j, z, 0 });
map[temp][j][z] = '#';
}
}
}
}
while (!q.empty()) {
point t = q.front();
q.pop();
for (int i = 0; i < 6; i++) {
int tz = t.z + next1[i][0]; // 2. 修改越界条件
int tx = t.x + next1[i][1];
int ty = t.y + next1[i][2];
if (tz < 0 || tz >= l || tx < 0 || tx >= r || ty < 0 || ty >= c || map[tz][tx][ty] == '#' || bookmap1[tz][tx][ty] == 1)
continue;
switch (map[tz][tx][ty]) { // 3. 使用switch语句判断
case '.':
q.push(point{ tz, tx, ty, t.step + 1 });
bookmap1[tz][tx][ty] = 1;
break;
case 'E':
printf("Escaped in %d minute(s).\n", t.step + 1);
while (!q.empty()) q.pop(); // 4. 退出循环
break;
}
}
}
// 5. 重置bookmap1数组和temp变量
for (int i = 0; i < l; i++) {
for (int j = 0; j < r; j++) {
for (int z = 0; z < c; z++) {
bookmap1[i][j][z] = 0;
}
}
}
temp = 0;
cin >> l >> r >> c;
}
return 0;
}
