请教一个申请住院医生和绿卡的问题# Immigration - 落地生根
l*c
1 楼
N皇后,写出来总是报错
说我placeQueen里面没有声明vector>& reta
好久没写C++了。请帮忙提个错
多谢
vector > solveNQueens(int n) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
vector> ret = new vector>();
if (n <= 0) {
return ret;
}
int * sol = new int[n];
placeQueen(sol, n, 0, ret);
return ret;
}
void placeQueen(int sol[], int n, int row, vector>& reta)
{
if (row == n) {
reta.push_back(transform(sol),n);
return;
}
for (int i = 0; i < n; i++) {
if (!taken(sol, row, i)) {
sol[row] = i;
placeQueen(sol, n, row+1, reta);
}
}
}
说我placeQueen里面没有声明vector
好久没写C++了。请帮忙提个错
多谢
vector
// Start typing your C/C++ solution below
// DO NOT write int main() function
vector
if (n <= 0) {
return ret;
}
int * sol = new int[n];
placeQueen(sol, n, 0, ret);
return ret;
}
void placeQueen(int sol[], int n, int row, vector
{
if (row == n) {
reta.push_back(transform(sol),n);
return;
}
for (int i = 0; i < n; i++) {
if (!taken(sol, row, i)) {
sol[row] = i;
placeQueen(sol, n, row+1, reta);
}
}
}