Home > Back-end >  Programming implementation: any input from the keyboard a 5 x 5 integer matrix, find out the differe
Programming implementation: any input from the keyboard a 5 x 5 integer matrix, find out the differe

Time:09-18

Programming implementation: any input from the keyboard a 5 x 5 integer matrix, calculate the maximum and the minimum output shows the difference between the results,

CodePudding user response:

Two-dimensional traversal, and the Max and min is not good,

CodePudding user response:

 
# include & lt; Iostream>
using namespace std;

Int main ()
{
Int I, j, arr [5] [5]={0};
Int the Max and min.

cout <"Input matrix data:" & lt; for (i=0; I<5; I++)
{
For (j=0; J<5; J++)
{
cin> Arr [I] [j];
}
}
Max=min=arr [0] [0].
For (I=0; I & lt; 5; I++)
{
For (j=0; J & lt; 5; J++)
{
If (Max & lt; Arr [I] [j])
Max=arr [I] [j];
If (min & gt; Arr [I] [j])
Min=arr [I] [j];
}
}

cout <"A maximum matrix is:" & lt;
return 0;
}
  • Related