vuoi
o PayPal
tutte le volte che vuoi
// Incremento valori matrice
#include <iostream>
#include <time.h>
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 incremento(int [massimo][massimo], int, int);
// ----- /PROTOTIPI ----- //
// ----- FUNZIONI ----- //
int dimensione_righe()
{
int nr;
cout<<"Inserisci il numero di righe: ";
cin>>nr;
while (nr>massimo)
{
cout<<"Errore. Inserisci il numero di righe: ";
cin>>nr;
}
return nr;
}
int dimensione_colonne()
{
int nc;
cout<<"Inserisci il numero di colonne: ";
cin>>nc;
while (nc>massimo)
{
cout<<"Errore. Inserisci il numero di colonne: ";
cin>>nc;
}
return nc;
}
void caricamento_matrice(int m[massimo][massimo], int nr, int nc)
{
for (int i=0; i<nr; i++)
{
for (int j=0; j<nc; j++)
{
cout<<"Inserisci l'elemento "<<i<<"x"<<j<<": ";
cin>>m[j];
}
}
}
void stampa_matrice(int m[massimo][massimo], int nr, int nc)
{
for (int i=0; i<nr; i++)
{
for (int j=0; j<nc; j++)
{
cout<<m[j]<<"\t";
}
cout<<endl;
}
}
void incremento(int m[massimo][massimo], int nr, int nc)
{
for (int i=0; i<nr; i++)
{
for (int j=0; j<nc; j++)
{
m[j]=m[j]+1;
}
}
}
// ----- /FUNZIONI ----- //
// ----- PROGRAMMA PRINCIPALE ----- //
int main()
{
int matrice[massimo][massimo];
int righe=dimensione_righe();
cout<<endl;
int colonne=dimensione_colonne();
cout<<endl;
caricamento_matrice(matrice, righe, colonne);
cout<<endl<<"Matrice caricata: "<<endl;
stampa_matrice(matrice, righe, colonne);
incremento(matrice, righe, colonne);
cout<<endl<<"Matrice finale: "<<endl;
stampa_matrice(matrice, righe, colonne);
return 0;
}
// ----- /PROGRAMMA PRINCIPALE ----- //
// Incremento valori matrice
#include <iostream>
#include <time.h>
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 incremento(int [massimo][massimo], int, int);
// ----- /PROTOTIPI ----- //
// ----- FUNZIONI ----- //
int dimensione_righe()
{ int nr;
cout<<"Inserisci il numero di righe: ";
cin>>nr;
while (nr>massimo)
{ cout<<"Errore. Inserisci il numero di righe: ";
cin>>nr;
}
return nr;
}
int dimensione_colonne()
{ int nc;
cout<<"Inserisci il numero di colonne: ";
cin>>nc;
while (nc>massimo)
{ cout<<"Errore. Inserisci il numero di colonne: ";
cin>>nc;
}
return nc;
}
void caricamento_matrice(int m[massimo][massimo], int nr, int nc)
{ for (int i=0; i<nr; i++)
{ for (int j=0; j<nc; j++)
{ cout<<"Inserisci l'elemento "<<i<<"x"<<j<<": ";
cin>>m[i][j];
}
}
}
void stampa_matrice(int m[massimo][massimo], int nr, int nc)