#### c++ recursion help

2嵌套的for循环将无法工作，因为我正在比较多个（> 2）值

``````event 1 @ 0100-0230, or @ 0200-0330
event 2 @ 1200-1500, or @ 0800-1100
event 3 @ 1200-1300, or @ 1300-1400, or @ 1400-1500
.
.
.
``````

``````event 1 @ 0100-2300, event 2 @ 0800-1100, event 3 @ 1200-1300 // will be printed out
event 2 @ 0200-0330, event 2 @ 1200-1500, event 3 @ 1200-1300 // will be ignored
``````
3 个回复

``````void compareOne(int compareWith, iterator b, iterator e) {
if (b == e) return;
if (compareWith == *b) {
// do something
}
compareOne(compareWith, b+1, e);
}

void compareAll(iterator b, iterator e) {
if (b == e) return;
compareOne(*b, b+1, e);
compareAll(b+1, e);
}
``````

``````for(int i = 0; i<v.size(); ++i)
{
for(int j = i+1; j < v.size(); ++j)
{
compare v[i] and v[j]
}
}
``````

``````using namespace std;
vector<int> v;
...
for (int i = 0; i < v.size() - 1; i++)
for (int j = i + 1; j < v.size(); j++)
if (v[i] == v[j])
cout << "Oops" << endl;
``````

``````vector::const_iterator beforelast = v.end(); --beforelast;
for (vector::const_iterator i = v.begin(); i != beforelast; ++i)
for (vector::const_iterator j = i + 1; j != v.end(); ++j)
if (*i == *j)
cout << "Oops" << endl;
``````

``````bool f(vector<int>& v, int lastidx)
{
int lastval = v[lastidx];
for (int i = 0; i < lastidx; i++)
if (v[i] == lastval)
return false;
return f(v, lastidx - 1);
}
``````

1 递归排列C ++

2 了解递归，C ++

3 基本C ++递归

4 C ++递归堆栈

5 C＃需要递归帮助

6 Kattis Putovanje 帮助 C++

7 C ++指针有帮助吗？

8 C++ 作业帮助

9 C ++ | 需要帮助从For循环功能->递归功能过渡

10 使用Horner方法计算多项式的C ++递归帮助