feat: Initial commit
This commit is contained in:
19
TemiEsame/sommaCornici.c
Normal file
19
TemiEsame/sommaCornici.c
Normal file
@@ -0,0 +1,19 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#define MAXN 10
|
||||
|
||||
int sommaCornici(int mat[MAXN][MAXN], int N, int vet[]) {
|
||||
int c = N / 2;
|
||||
|
||||
for (int i = 0; i < c; i++) {
|
||||
vet[i] = mat[i][i] + mat[N-i-1][i] + mat[N-i-1][N-i-1] + mat[N-i-1][N-i-1];
|
||||
|
||||
for (int j = i; j < N-i-1; j++) {
|
||||
vet[i] += mat[i][j] + mat[j][i] + mat[N-i-1][j] + mat[j][N-i-1];
|
||||
}
|
||||
}
|
||||
|
||||
if (N % 2 == 1) {
|
||||
vet[c+1] = mat[c][c];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user