Ciao. come faccio a passare in c++ una matrice ad una funzione?
io ho fatto così:
ma non va... non capisco...codice:#include <iostream> using namespace std; int const nmax=100; void stampa(int* matrice, int n) { cout << endl; for (int i=0;i<n;i++) { for (int j=0;j<n;j++) { cout << matrice[i][j] << " "; } cout << endl; } cout << endl; } int main() { int matrice[nmax][nmax]; int n; cout << "Inserisci la dimensione della matrice quadrata: "; cin >> n; for (int i=0;i<n;i++) { for (int j=0;j<n;j++) { cout << "Inserisci l'elemento [" << i << "][" << j << "]: "; cin >> matrice[i][j]; } } stampa(&matrice, n); system("pause"); return 0; }
ciao a tutti