deny_1515
Ominide
1 min. di lettura
Vota

Concetti Chiave

  • The program initializes a 2D array with a maximum size of 50x50 elements and provides functions for input and output operations.
  • It includes functions to load data into the matrix, print the matrix, and find both the maximum and minimum values within it.
  • There is a specific function to print the elements of the main diagonal of the matrix, showcasing the diagonal traversal logic.
  • The dimension of the matrix is determined by user input, which is validated to be within the maximum permissible size.
  • Several syntax errors, particularly with operators and loops, need to be corrected for successful compilation and execution.

#include
#define MAX 50
using namespace std;

int chiedidimensione();
void Caricamento(int M[MAX][MAX], int r, int c);
void Stampa(int M[MAX][MAX],int r,int c);
void Max(int M[MAX][MAX], int r, int c);
void Min(int M[MAX][MAX], int r, int c);
void DiagonalePrincipale(int M[MAX][MAX], int r, int c);
int main()
{
int r, c;
int M[MAX][MAX];
cout r=chiedidimensione();
cout c=chiedidimensione();
Caricamento(M, r, c);
Max(M, r, c);
Min(M, r, c);
DiagonalePrincipale(M,r,c);
return 0;
}

int chiedidimensione()
{
int d;
do{
cin>>d;
}while(dMAX);
return d;
}
void Caricamento(int M[MAX][MAX], int r, int c){
cout for(int x=0; x for(int y=0; y cin>>M[x][y];
}
}
cout Stampa(M,r,c);
}
void Stampa(int M[MAX][MAX],int r,int c){
for(int x=0;x for(int y=0; y cout }cout }
}
void Max(int M[MAX][MAX], int r, int c){
int max;
for(int i=0;i for(int j=0; j if(max[j]){
max=M[j];
}
} }
cout }

void Min(int M[MAX][MAX], int r, int c) {
int min;
for(int i=0; i for(int j=0; j if(min>M[j]) {
min=M[j];
}
} }
cout }
void DiagonalePrincipale(int M[MAX][MAX], int r, int c)
{
cout for(int i=0; i for(int j=0; j if(i==j){
cout[j];
}
}
}
}

Domande e risposte

Hai bisogno di aiuto?
Chiedi alla community