if (!paths.empty()) { for (int j = 0; j < paths.size(); j++) { // 判断两个路径的第一个节点是否相同 if (paths[i][0]->x == paths[j][0]->x && paths[i][0]->y == paths[j][0]->y) { std::cout << "i: " << i << " j: " << j << std::endl; } } }else { std::cout << "Paths is empty!" << std::endl; },將條件改爲,paths的長度必須大於0
时间: 2024-03-28 19:39:14 浏览: 44
install.rar
好的,你的问题是将这段代码中的条件改为必须满足 paths 的长度大于0,那么修改后的代码如下:
if (paths.size() > 0) {
for (int j = 0; j < paths.size(); j++) {
// 判断两个路径的第一个节点是否相同
if (paths[i][0]->x == paths[j][0]->x && paths[i][0]->y == paths[j][0]->y) {
std::cout << "i: " << i << " j: " << j << std::endl;
}
}
} else {
std::cout << "Paths is empty!" << std::endl;
}
阅读全文