Home > Back-end >  Find the maximum value of two dimensional array
Find the maximum value of two dimensional array

Time:03-12

Title description:
Write a program to find m rows n columns of two-dimensional maximum of all elements in the array, the input line m + 1: the value of the first behavior of m and n, the following m lines for two-dimensional arrays, each line including n number,
For example, enter the following
3 3
1 2 3
4 5 6
7 8 9
The first line of 3 3 means 3 rows 3 columns
The output of
9
Enter
3 3
1 2 3
4 5 6
7 8 9

O
9

The sample input
3 3
1 2 3
4 5 6
7 8 9

Sample output
9

Procedure is as follows:
# include & lt; Stdio. H>
# define N 100
Void main ()
{
Int a [N] [N], n1, and n2, I, j, Max, t;
The scanf (" % d % d ", & amp; N1, & amp; N2);//the row and column of the input array
for(i=0; ifor(j=0; jThe scanf (" % d ", & amp; A [I] [j]);
Max=a [0] [0];
for(i=0; ifor(j=0; jIf (max{
T=a, [I] [j].
A [I] [j]=Max;
Max=t;
}
Printf (" % d \ n ", Max).//the biggest number in the output array
}

CodePudding user response:

 # include & lt; Stdio. H> 

# define N 100

Int main ()
{
Int a [N] [N], n1, and n2, I, j, Max, t;
The scanf (" % d % d ", & amp; N1, & amp; N2);//the row and column of the input array
If (n1 & gt; N)
N1=N;
If (n2 & gt; N)
N2=N;
for(i=0; ifor(j=0; jThe scanf (" % d ", & amp; A [I] [j]);

Max=a [0] [0];
for(i=0; ifor(j=0; jIf (max
{
Max=a, [I] [j].
/*
T=a, [I] [j].
A [I] [j]=Max;
Max=t;
*/
}
Printf (" % d \ n ", Max).//the biggest number in the output array
}

For your reference ~

CodePudding user response:

The
reference 1/f, confident boy reply:
 # include & lt; Stdio. H> 

# define N 100

Int main ()
{
Int a [N] [N], n1, and n2, I, j, Max, t;
The scanf (" % d % d ", & amp; N1, & amp; N2);//the row and column of the input array
If (n1 & gt; N)
N1=N;
If (n2 & gt; N)
N2=N;
for(i=0; ifor(j=0; jThe scanf (" % d ", & amp; A [I] [j]);

Max=a [0] [0];
for(i=0; ifor(j=0; jIf (max
{
Max=a, [I] [j].
/*
T=a, [I] [j].
A [I] [j]=Max;
Max=t;
*/
}
Printf (" % d \ n ", Max).//the biggest number in the output array
}

For reference ~

Thank you very much, the bosses help me correct!
  • Related