#include <iostream>
#include <vector>
#include <cmath>
struct bk {
double p[2];
};
double calculateDistance(const bk& a, const bk& b) {
double dx = a.p[0] - b.p[0];
double dy = a.p[1] - b.p[1];
return std::sqrt(dx * dx + dy * dy);
}
int main() {
std::vector<bk> vk(30), vm(40);
std::vector<std::vector<bk>> vU;
// Iterate over vk and vm vectors
for (int i = 0; i < vk.size(); ++i) {
for (int j = 0; j < vm.size(); ++j) {
// Calculate the distance between vk[i] and vm[j]
double distance = calculateDistance(vk[i], vm[j]);
// Check if the distance is less than 0.05
if (distance < 0.05) {
// Add vk[i] and vm[j] to vU
vU.push_back({vk[i], vm[j]});
// Remove vm[j] from vm vector
vm.erase(vm.begin() + j);
// Decrement j so that we don't skip the next element
--j;
}
}
}
return 0;
}
vector 找同心圆逻辑
最新推荐文章于 2024-11-05 21:37:39 发布