-
Notifications
You must be signed in to change notification settings - Fork 0
/
4sem.ex09.c
53 lines (43 loc) · 1.13 KB
/
4sem.ex09.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <stdio.h>
#include <stdlib.h>
/* PROTOTYPES */
int Ler_Num_Matriz ( int linha, int coluna, int m[linha][coluna] );
int Calcular_Soma_Not_Diag_Princ_Sec ( int *soma, int linha, int coluna,
int m[linha][coluna] );
int main()
{
int linha = 4, coluna = 4;
int matriz [linha][coluna];
int soma_not_diag_princ_sec = 0;
int *pSoma = &soma_not_diag_princ_sec;
Ler_Num_Matriz(linha,coluna,matriz);
Calcular_Soma_Not_Diag_Princ_Sec(pSoma,linha,coluna,matriz);
printf("Soma: %i \n",soma_not_diag_princ_sec);
return 0;
}
int Ler_Num_Matriz ( int linha, int coluna, int m[linha][coluna] )
{
for (int i = 0; i < linha; i++ )
{
for ( int j = 0 ; j < coluna ; j++ )
{
scanf("%i",&m[i][j]);
}
}
return 0;
}
int Calcular_Soma_Not_Diag_Princ_Sec ( int *soma, int linha, int coluna,
int m[linha][coluna] )
{
for ( int j = 0 ; j < coluna ; j++ )
{
for ( int i = 0; i < linha; i++ )
{
if ( !(i == j) && !( (i+j) == (linha - 1)) )
{
*soma += m[i][j];
}
}
}
return 0;
}