Advertisement
maha_kaal

ianna C

Aug 24th, 2013
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.31 KB | None | 0 0
  1.     #include <stdio.h>
  2.      
  3.     int verifica_righe(int matr[][4], int dim1, int dim2)
  4.     {
  5.             int i = 0;
  6.             int j;
  7.            
  8.             for(i = 0; i < dim1; i++)
  9.             {
  10.                     int temp = 0;
  11.                     while(j < dim2-1)
  12.                     {
  13.                             temp += matr[i][j];
  14.                             j++;
  15.                     }
  16.                     if(temp == matr[i][j])
  17.                     {
  18.                             return 0;
  19.                     }
  20.             }
  21.             return 1;
  22.     }
  23.     int main(int argc, const char* argv[])
  24.     {
  25.             int matrice[4][4] = {1, 1, 1, 3,
  26.                                  2, 2, 2, 6,
  27.                                  3, 3, 3, 9,
  28.                                  4, 4, 4, 12};
  29.             printf("Verifico se l'ultimo elemento di ogni riga della matrice bidimensionale del programma\n");
  30.             printf("e' uguale alla somma degli altri...\n");
  31.            
  32.             if (!verifica_righe(matrice, 4, 4))
  33.             {
  34.                     printf("...sì, e' così! Fine programma.\n");
  35.             }
  36.             else
  37.             {
  38.                     printf("...no, non e' così. Fine programma.\n");
  39.             }
  40.            
  41.             return 0;      
  42.                    
  43.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement