在每轮新的puzzle时要清空'\n',建议这么写,既能过滤'\n'又能不丢失地图信息和结束符号'Z':
char ch; while((ch = getchar()), ch == '\n'); // cin >> ch; if(ch == 'Z') break;