Video appunto: C++ - Decremento valori matrice
C++ - Decremento valori matrice
// Decremento valori matrice
#include
#include
using namespace std;
// ----- VARIABILI GLOBALI ----- //
const int massimo=100;
// ----- /VARIABILI GLOBALI ----- //
// ----- PROTOTIPI ----- //
int dimensione_righe();
int dimensione_colonne();
void caricamento_matrice(int [massimo][massimo], int, int);
void stampa_matrice(int [massimo][massimo], int, int);
void decremento(int [massimo][massimo], int, int);
// ----- /PROTOTIPI ----- //
// ----- FUNZIONI ----- //
int dimensione_righe()
{
int nr;
cout cin>>nr;
while (nr>massimo)
{
cout cin>>nr;
}
return nr;
}
int dimensione_colonne()
{
int nc;
cout cin>>nc;
while (nc>massimo)
{
cout cin>>nc;
}
return nc;
}
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 }
}
void decremento(int m[massimo][massimo], int nr, int nc)
{
for (int i=0; i
for (int j=0; j
m[j]=m[j]-1;
}
}
}
// ----- /FUNZIONI ----- //
// ----- PROGRAMMA PRINCIPALE ----- //
int main()
{
int matrice[massimo][massimo];
int righe=dimensione_righe();
cout int colonne=dimensione_colonne();
cout caricamento_matrice(matrice, righe, colonne);
cout stampa_matrice(matrice, righe, colonne);
decremento(matrice, righe, colonne);
cout stampa_matrice(matrice, righe, colonne);
return 0;
}
// ----- /PROGRAMMA PRINCIPALE ----- //