fork(1) download
  1. #include <stdio.h>
  2.  
  3. int soma_matriz(int n, int mat[n][n]) {
  4. int soma = 0;
  5. for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) if (i < j) soma += mat[i][j];
  6. return soma;
  7. }
  8.  
  9. int main() {
  10. int mat[3][3] = {{1, 1, 1}, {1, 1, 1}, {1, 1, 1}};
  11. printf("O valor e %d", soma_matriz(3, mat));
  12. }
  13.  
  14. //https://pt.stackoverflow.com/q/498855/101
Success #stdin #stdout 0s 4696KB
stdin
Standard input is empty
stdout
O valor e 3