我不明白为什么二线>父显示我2 载体包含的所有时间Find_if奇怪值
{{2,4,0},{2,5,0},{2,6,0},{1,2,0},{8,7,0},{7,3,0},{10,9,0},{11,9,0},{3,9,0}, {1,3,0}, {0,1,11}}
在VS 2013我有它正在Ideone得到一个错误的对的,但它锯我所有的时间二阶>父= 2
struct tester {
int parent, number, child;
};
std::vector <tester> test;
test.push_back({ 0,1, 11 });
std::vector <tester>::iterator first, second;
for (first = test.begin() + 1, second = test.begin(); first != test.end(); ++first) {
if (first->parent <= second->parent) {
parent = first->parent;
auto pred = [parent](pracownik& item) {
return item.parent == parent;
};
second = std::find_if(first - 1, test.begin(), pred);
first->child = first - second;
if (first->child == 1) first->child = 0;
second = first;
}
}
方案应的矢量改变为:
{ {2,4,0},{2,5,0},{2,6,0},{1,2,3},{8,7,0},{7,3,1},{10,9,0},{11,9,0},{3,9,2}, {1,3,5}, {0,1,11}}
您应该阅读[如何创建最小,完整和可验证示例](http://stackoverflow.com/help/mcve)。如果您提供可自行运行的示例,则会更好。没有这个很难完全理解你的问题。 –