#include "dowsing.h"
#include <vector>
using namespace std;
typedef pair<int, int> pii;
int getdiff(int x, int y) {
int t = 1;
if (x == 1 || y == 1) t = 2;
if (t == 2 && (x == 2 || y == 2)) t = 3;
return t;
}
void FindTreasure(int N) {
vector <int> Vu;
for (int i = 1; i <= N; i++) {
if (Detect(i, i)) Vu.push_back(i);
}
if (Vu.size() == 2) {
int t = getdiff(Vu[0], Vu[1]);
if (Detect(Vu[0], t)) Report(Vu[0], Vu[1]);
else Report(Vu[1], Vu[0]);
return;
}
int t1 = N - 1, t2 = N;
for (int i = 1; i <= N / 2 - 1; i++) {
t1 = i * 2 - 1, t2 = i * 2;
if (Detect(t1, t2)) break;
}
if (i > N / 2 - 1) t1 = N - 1, t2 = N;
int x = getdiff(t1, t2);
if (Detect(t1, x)) Report(t1, t1);
else Report(t2, t2);
return;
}
Compilation message
dowsing.cpp: In function 'void FindTreasure(int)':
dowsing.cpp:30:6: error: 'i' was not declared in this scope
if (i > N / 2 - 1) t1 = N - 1, t2 = N;
^