#include<stdio.h>
#define RIGA 3
#define COLONNA 4
int main(){
int matrice[RIGA][COLONNA];
int somma_riga[RIGA]={0},somma_colonne[COLONNA]={0};
int j , i,sommaTotale=0;
printf("Inserisci gli elementi della matrice [%dx%d]:",RIGA,COLONNA);
for(i=0;i < RIGA ; i++){
for(j=0; j < COLONNA;j++){
printf("\nELEMENTO [%d][%d]",i,j);
scanf("%d",&matrice[i][j]); } }
for(i=0;i < RIGA ; i++){
for(j=0; j < COLONNA;j++){
somma_riga[i]+=matrice[i][j];//funziona perche gli array delle somme sono legate dai pedici somma_colonne[j]+=matrice[i][j];
somma_colonne[j]+=matrice[i][j];
sommaTotale+=matrice[i][j];}}
printf("\n----------------tabella dei risultati------------- \n\n");
for(i=0;i < RIGA ; i++){
for(j=0; j < COLONNA;j++){
printf("%4d ",matrice[i][j]);}
printf("| %4d \n",somma_riga[i]);}
printf("--------------------+-----\n");
for(j=0; j < COLONNA;j++){
printf("%4d ",somma_colonne[j]);}
printf(" %d",sommaTotale);
}
To embed this project on your website, copy the following code and paste it into your website's HTML: