/*Sia data una matrice di interi dimensioni M X N.Scrivere una funzione che restituisca TRUE se vi sono due righe e due colonne consecutive di elementi uguali tra loro*/ #include #define SIZER 4 #define SIZEC 5 int confronto(int matrice[SIZER][SIZEC]) { int r = 0, c = 0, result = 0, isUguale = 0; //printf("Start:\n"); while ((r < SIZER - 1) && !isUguale) { while ((c < SIZEC - 1) && !isUguale) { //printf("\tmatrice[%d][%d]: %d - matrice[%d][%d]: %d;\n", r, c, matrice[r][c], r, c + 1, matrice[r][c + 1]); //printf("\tmatrice[%d][%d]: %d - matrice[%d][%d]: %d;\n\n", r, c, matrice[r][c], r + 1, c + 1, matrice[r + 1][c + 1]); if (matrice[r][c] == matrice[r][c + 1]) { //printf("\t\tPassed 1;\n"); if ((matrice[r][c] == matrice[r + 1][c]) && (matrice[r][c] == matrice[r + 1][c + 1])) { //printf("\t\tPassed 2;\n"); isUguale = 1; } else { c++; } } else { c++; } } c = 0; r++; } return isUguale; } int main() { int matrice[SIZER][SIZEC]= { {21, 31, 54, 74, 59}, {31, 31, 74, 74, 59}, {51, 31, 74, 74, 59}, {21, 31, 34, 44, 59} }; if (confronto(matrice)) { printf("TRUE\n"); } else { printf("FALSE\n"); } system("pause"); return 0; }