利用二维数组存储一个3行4列的单位矩阵,并输出最大值和最小值

#include<iostream.h>
void main()
{
<wbr>int i,j,a[3][4];<br><wbr>int max,min;<br><wbr>for(i=0;i&lt;3;i++)<br><wbr>{<br><wbr><wbr>for(j=0;j&lt;4;j++)<br><wbr><wbr><wbr>cin&gt;&gt;a[i][j];<br><wbr>}<br><wbr>for(i=0;i&lt;=2;i++)<br><wbr>{<wbr><wbr><br><wbr><wbr>cout&lt;&lt;endl;<br><wbr><wbr>for(j=0;j&lt;=3;j++)<br><wbr><wbr>cout&lt;&lt;a[i][j]&lt;&lt;"\t";<br><wbr>}<br><wbr><wbr><wbr> max=a[0][0];<br><wbr><wbr><wbr> min=a[0][0];<br><wbr><wbr><wbr> for (i=0 ; i&lt;3 ; ++i)<br><wbr><wbr>for ( j=0; j&lt;4 ;++j)<br><wbr><wbr><wbr><wbr><wbr><wbr> {<wbr> if ( max&lt;=a[i][j])<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> max=a[i][j];<br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><br><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr><wbr> if ( min&gt;=a[i][j])<br><wbr><wbr><wbr> min=a[i][j];</wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>

<wbr><wbr>}<br><wbr>cout&lt;&lt;"max="&lt;&lt;max&lt;&lt;" "&lt;&lt;"min="&lt;&lt;min&lt;&lt;endl;<br> }</wbr></wbr></wbr>

你可能感兴趣的:(二维数组)