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
^
Web sitelerinin çevrimiçi olarak, değişkenlerin birkaç kez oluşturulduğunu veya STL kitaplığında zaten işlev adı bulunduğunu söyledim. Her iki durumu da kontrol ettim ve onlar benim problemim için geçerli değiller. Dolguya neden olan problem mi yoksa başka değişken mi, yoksa fonksiyon mu?hatası: Aşırı yüklenmiş durumun, belirsiz olduğunu belirten bir kişi bana herhangi bir hata yaptığını söyleyebilir mi?
senin "sokulabilir" işlevidir aşırı geçerli bir kullanım durumu? –
Burada anlamlı bir cevap vermek için neredeyse yeterli bilgi yok, ancak ad alanı std'yi kullandığınız anlaşılıyor. Standart kütüphanede aynı şekilde isimlendirilmiş bir fonksiyona sahip bir hurdaya girmeyi tanımladığınız işlev gibi, bolluk için bolca yer vardır. – user4581301