bool find_solutions(const string if_need_all, vector< vector<char> > table, vector<int> ships, int row[], int col[]){
sort(ships.begin(), ships.end(), greater<int>());//sort the ship length in descending order
static int counter = 0; //counter that tracks if the ship is to be placed vertically or horizontally
static int s = 0; //index of ship using
int fill;//ship to fill
int filling;//keep track how much the ship has been filled
if(s == ships.size()) return true;
for(unsigned int i = 0; i<table.size(); ++i){
filling = 0;
fill = ships[s];
for(unsigned int j = 0; j<table[i].size(); ++j){
if(counter == 0 && insertable(table,row,col,i,j,counter,fill)){
while(filling<fill){
table[i][j+filling] = fill;
col[j+filling]--;
filling++;
}
row[i] -= fill; s++;
find_solutions(if_need_all, table, ships, row,col);
}
else{
counter++;
}
if(counter == 1 && insertable(table,row,col,i,j,counter,fill)){
while(filling<fill){
table[i+filling][j] = fill;
row[i+filling]--;
filling++;
}
col[j] -= fill; s++;
find_solutions(if_need_all, table, ships, row, col);
}
else{
counter--;
}
}
}
if(s != ships.size()) return false;
else return true;
}
main.cpp: In function ‘bool find_solutions(std::__cxx11::string, std::vector<std::vector<char> >, std::vector<int>, int*, int*)’:
main.cpp:277:67: error: call of overloaded ‘insertable(std::vector<std::vector<char> >&, int*&, int*&, unsigned int&, unsigned int&, int&, int&)’ is ambiguous
if(counter == 0 && insertable(table,row,col,i,j,counter,fill)){
^
main.cpp:13:6: note: candidate: bool insertable(const std::vector<std::vector<char> >&, const int*, const int*, int, int, int, int)
bool insertable(const vector< vector<char> >& inboard, const int r[], const int c[],
^
main.cpp:125:6: note: candidate: bool insertable(std::vector<std::vector<char> >, const int*, const int*, int, int, int, int)
bool insertable(const vector< vector<char> > inboard,const int r[], const int c[],co
^
может кто-нибудь сказать мне, какую ошибку я сделал? Я искал в Интернете, что веб-сайты говорят, что это либо переменная, созданная несколько раз, либо имя функции уже существует в библиотеке STL. Я проверил оба условия, и они не относятся к моей проблеме. Это проблема с заполнением или другая переменная, или это функция?ошибка: звонок перегружен неоднозначно
где ваш «вставной» функция? –
Не достаточно информации здесь, чтобы дать осмысленный ответ, но похоже, что вы используете 'namespace std'. Существует множество возможностей для гадости, таких как функция, которую вы определяете при входе в лом с идентично названной функцией в стандартной библиотеке. – user4581301