// Sommare i numeri pari della seconda diagonale (matrice)
#include
using namespace std;
// ----- VARIABILI GLOBALI ----- //
const int massimo=100;
// ----- /VARIABILI GLOBALI ----- //
// ----- PROTOTIPI ----- //
int dimensione();
void caricamento_matrice(int [massimo][massimo], int, int);
void stampa_matrice(int [massimo][massimo], int, int);
int somma_pari(int [massimo][massimo], int, int);
// ----- /PROTOTIPI ----- //
// ----- FUNZIONI ----- //
int dimensione()
{
int n;
cout
cin>>n;
while (n>massimo)
{
cout
cin>>n;
}
return n;
}
void caricamento_matrice(int m[massimo][massimo], int nr, int nc)
{
for (int i=0; i
for (int j=0; j
cout
cin>>m[j];
}
}
}
void stampa_matrice(int m[massimo][massimo], int nr, int nc)
{
for (int i=0; i
for (int j=0; j
cout[j]
}
cout
}
}
int somma_pari(int m[massimo][massimo], int nr, int nc)
{
int x=0;
for (int i=0; i
for (int j=0; j
if (i+j==nr-1)
{
if (m[j]%2==0)
{
x=x+m[j];
}
}
}
}
return x;
}
// ----- /FUNZIONI ----- //
// ----- PROGRAMMA PRINCIPALE ----- //
int main()
{
int matrice[massimo][massimo];
int righe=dimensione();
int colonne=righe;
cout
caricamento_matrice(matrice, righe, colonne);
cout
stampa_matrice(matrice, righe, colonne);
int somma=somma_pari(matrice, righe, colonne);
cout
return 0;
}
// ----- /PROGRAMMA PRINCIPALE ----- //