void main(){
int num[5][5];
int i,j;
Printf ("Please enter a series of 5 * 5: \ n");
for(I = 0; I<5; I++)// Output a 5 * 5 array.
for(j = 0; j & lt5; j++)
scanf("%d ",& ampnum[I][j]);
int max = num[0][0];
for(I = 0; I<5; I++)// Find the maximum value of the main diagonal.
for(j = 0; j & lt5; j++)
if(I = = j & amp; & ampnum[I][j]& gt; Max)
max = num[I][j];
Printf ("The maximum value on the main diagonal is:% d \ n", max);
for(I = 0; I<5; I++)// Find the position of the maximum value of the main diagonal.
for(j = 0; j & lt5; j++)
If (i==j)
if(num[i][j]==max){
Printf ("its position is %d row, %d column \ n", I+ 1, j+1);
Break;
}
}
The realization sequence of the program is: input data, find out the maximum value of the main diagonal, and find out the line number and column number where the maximum value is located.
Main diagonal:
In an n-order square matrix (or n-order determinant), the position of n elements on the diagonal from the upper left corner to the lower right corner is called the main diagonal of the n-order square matrix (or n-order determinant).
Extended data:
Scanf ("input controller", input parameters);
Function: Convert the characters input by the keyboard into data in the specified format in the input control symbol, and then store it in a variable with the value of the input parameter as the address.
For example:
scanf("%d ",& ampI); ?
Enter control characters:
When the operating system receives keyboard data, it always treats it as a character. At this time, it needs to be transformed through the "input controller". The meaning of %d is to convert these legal characters entered from the keyboard into decimal numbers. For example, input 123, and after %d conversion, the character 123 is the number 123.
& is an address operator,&; Add the variable & after it, which means "address of variable", so&; Represents the address of the variable i. I, also called "fetch address I", is equivalent to storing data in a variable, and the address of this variable is the address of variable I.