以下是基于pcl库遍历std::vector all,并将std::vector idx中没有的索引存入std::vector idx11的C++代码示例:

#include <iostream>
#include <vector>
#include <pcl/point_types.h>

int main() {
    std::vector<int> all{0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    std::vector<int> idx{1, 3, 5, 7, 9};
    std::vector<int> idx11;

    // 遍历all,并将不在idx中的索引存入idx11
    for (int i = 0; i < all.size(); ++i) {
        bool found = false;

        // 检查当前索引是否在idx中
        for (int j = 0; j < idx.size(); ++j) {
            if (all[i] == idx[j]) {
                found = true;
                break;
            }
        }

        // 如果当前索引不在idx中,则将其存入idx11
        if (!found) {
            idx11.push_back(all[i]);
        }
    }

    // 输出结果
    std::cout << "idx11: ";
    for (const auto& index : idx11) {
        std::cout << index << " ";
    }
    std::cout << std::endl;

    return 0;
}

在上述代码中,我们首先定义了两个vector,all表示所有的索引,idx表示已经存在的索引。然后我们遍历all,对于每个索引,检查其是否在idx中。如果不在,则将其存入idx11。最后,我们输出idx11的内容。

注意:这段代码中未使用pcl库,仅使用了标准C++库。如果需要使用pcl库的其他功能,请根据具体需求进行修改

基于pcl库遍历stdvectorint all;将stdvectorintidx内没有的索引存入stdvectorintidx11的c++代码

原文地址: https://www.cveoy.top/t/topic/h4k2 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录