The problem is that the expected output is not correct. Output I am getting it is shared below (expected output vs my code output).
- PRECONDITION: it takes a map represented by a matrix of dimensions col x row, which 'A' represents a place where there is WATER, and 'T' where its LAND.
- POSTCONDITION: Returns the count of isles from the map. An island is a set of adyacents lands orthogonal or diagonal (it could be only one).
Index of the map given must be used as a map [c][r] donde c and r belong to the column and row respectively. Matrix given must be returned without modifications.
Example 1
Input: (['T','A','T','A'], 4, 1)
Output: 2
Example 2
Input: (['T','T','A'
           'A','A','T'
           'A','A','A'
           'T','T','A'], 3, 4)
Output: 2
OUTPUT(EXPECTED VS MINE)
Prueba Islas 1 -> ERROR salida incorrecta Parametros de entrada: ['T','A','T','A','T','A'], 6, 1 Se esperaba: 3
Se recibio: 0
Prueba Islas 2 -> ERROR salida incorrecta Parametros de entrada: ['T','A','T','A','T','A','T','T','T','T','T','T'], 6, 2 Se esperaba: 1
Se recibio: 0
Prueba Islas 3 -> ERROR salida incorrecta Parametros de entrada: ['T','A','T','A','T','T','T','A','T','A','A','T','T','A','A','T','T','T','T','A'], 10, 2 Se esperaba: 2
Se recibio: 0
Prueba Islas 4 -> ERROR salida incorrecta Parametros de entrada: ['T','A','T','A','T','A','A','T','A','T','A','T','T','A','A','T','A','T','T','T','T','A','T','T'], 6, 4 Se esperaba: 1
Se recibio: 0
Prueba Islas 5 -> ERROR salida incorrecta Parametros de entrada: ['A','A','A','A','A','A','A','A','A','A','A','T','T','A','T','T','A','T','T','A','A','T','T','A','T','T','A','T','T','A','A','A','A','A','A','A','A','A','A','A'], 10, 4 Se esperaba: 3
Se recibio: 0
Prueba Islas 6 -> ERROR salida incorrecta Parametros de entrada: ['A','T','T','T','T','T','A','T','T','T','A','T','A','A','A','T','A','T','A','T','A','T','A','A','T','T','A','T','A','T','A','T','T','T','T','A','A','A','T','A'], 10, 4 Se esperaba: 2
Se recibio: 0
PRUEBAS FUNCION PruebaIslas HAY PRUEBAS INCORRECTAS
This is what I´ve tried to do:
int islas(char** mapa, int col, int fil)
   void borrarIsla(char** mapa, int col, int fil, int pCol, int pFil) {
    mapa[pCol][pFil] = 'A';
    int vectPosC[8] = { 1,1,0,-1,-1,-1,0,1 };
    int vectPosF[8] = { 0,1,1,1,0,-1,-1,-1 };
    int u, v;
    for (int k = 0; k < 8; k++) {
        u = pCol;
        v = pFil;
        u += vectPosC[k];
        v += vectPosF[k];
        if (dentro(col, fil, u, v) && mapa[u][v] == 'T') {
            borrarIsla(mapa, col, fil, u, v);
        }
    }
}
bool dentro(int col, int fil, int u, int v) {
    return u >= 0 && u < col && v >= 0 && v < fil;
}
char** copiaListaStr(char** listPalabras, int largoVec) {
    if (largoVec > 0) {
        char** aux = new char* [largoVec];
        for (int i = 0; i < largoVec; i++)
        {
            int largoPalabra = largoStr(listPalabras[i]);
            aux[i] = copiarStr(listPalabras[i], largoPalabra);
        }
        return aux;
    }
    return NULL;
}
char* copiarStr(char* palabra, int largo) {
    char* aux = new char[largo + 1];
    for (int i = 0; i < largo; i++)
    {
        aux[i] = palabra[i];
    }
    aux[largo] = '\0';
    return aux;
}
int largoStr(char* vec) {
    int i = 0;
    while (vec[i])
    {
        i++;
    }
    return i;
}
int islas(char** mapa, int col, int fil) {
    int cont = 0;
    char** mapAux = copiaListaStr(mapa, col);
    for (int j = 0; j < col; j++) {
        for (int i = 0; i < fil; i++) {
            if (mapAux[j][i] == 'T') {
                cont++;
                borrarIsla(mapAux, col, fil, j, i);
            }
        }
        delete[] mapAux[j];
    }
    delete[] mapAux;
    return cont;
}
