# 一维数组转二维数组

m = X / 5
n = X % 5

#define B[(x)][(y)]  A[((x*m)+(y%n)]

#include<stdio.h> 
<span style="white-space:pre">	</span>int MAX,MIN; 
<span style="white-space:pre">	</span>int maxi,maxj,mini,minj;
 void main() 
{  <span style="white-space:pre">	</span>void result(int x[][5],int m,int n); 
 <span style="white-space:pre">	</span>int a[5][5],max,min,i,j; 
<span style="white-space:pre">	</span> for(i=0;i<5;i++)   
<span style="white-space:pre">		</span>for(j=0;j<5;j++)   
 <span style="white-space:pre">		</span>scanf("%d",&a[i][j]); 
 <span style="white-space:pre">	</span>MAX=MIN=a[0][0]; 
 <span style="white-space:pre">	</span>maxi=maxj=mini=minj=0;    
<span style="white-space:pre">	</span> result(a,5,5); 
 <span style="white-space:pre">	</span>printf("MAX=%d,maxi=%d,maxj=%d\n",MAX,maxi,maxj); 
 <span style="white-space:pre">	</span>printf("MIN=%d,mini=%d,minj=%d\n",MIN,mini,minj);
 } 
</pre><pre name="code" class="cpp">void result(int x[][5],int m,int n) 
{  <span style="white-space:pre">	</span>int i,j; 
<span style="white-space:pre">	</span> for(i=0;i<m;i++)  
 <span style="white-space:pre">		</span>for(j=0;j<n;j++)  
 <span style="white-space:pre">	</span>{    if(x[i][j]>MAX)    
<span style="white-space:pre">		</span>{     MAX=x[i][j];    
<span style="white-space:pre">	</span> <span style="white-space:pre">	</span>      maxi=i;     
 <span style="white-space:pre">		</span>      maxj=j;    
<span style="white-space:pre">		</span>}   
<span style="white-space:pre">	</span>    if(x[i][j]<MIN)   
 <span style="white-space:pre">		</span>{     MIN=x[i][j];   
 <span style="white-space:pre">		</span>       mini=i;     
                       minj=j;   
<span style="white-space:pre">		</span> }   
<span style="white-space:pre">	</span>} 
}  

 #include<stdio.h>
<span style="white-space:pre">	</span>int MAX,MIN;
<span style="white-space:pre">	</span>int maxi,maxj,mini,minj; 
void main() 
{  <span style="white-space:pre">	</span>void result(int x[][5],int m,int n); 
 <span style="white-space:pre">	</span>int a[5][5],max,min,i,j;  
<span style="white-space:pre">	</span>for(i=0;i<5;i++)  <span style="white-space:pre">	</span>
<span style="white-space:pre">		</span>for(j=0;j<5;j++)    
<span style="white-space:pre">		</span>scanf("%d",&a[i][j]);  
<span style="white-space:pre">		</span>MAX=MIN=a[0][0];  
<span style="white-space:pre">		</span>maxi=maxj=mini=minj=0;    
<span style="white-space:pre">		</span>result(a,5,5); 
}
 void result(int x[][5],int m,int n) 
{  <span style="white-space:pre">	</span>int i,j;  
<span style="white-space:pre">	</span>for(i=0;i<m;i++)   
<span style="white-space:pre">		</span>for(j=0;j<n;j++)   
<span style="white-space:pre">		</span>{    if(x[i][j]>MAX)    
<span style="white-space:pre">		</span>        MAX=x[i][j];   
                     if(x[i][j]<MIN)     
<span style="white-space:pre">			</span>MIN=x[i][j];  
<span style="white-space:pre">		</span> }  
<span style="white-space:pre">	</span>for(i=0;i<m;i++)   
<span style="white-space:pre">		</span>for(j=0;j<n;j++)   
<span style="white-space:pre">	</span>        {    if(x[i][j]==MAX)    
<span style="white-space:pre">			</span>{     MAX=x[i][j];     
<span style="white-space:pre">				</span>maxi=i;     
<span style="white-space:pre">				</span>maxj=j;     
<span style="white-space:pre">				</span>printf("MAX=%d,maxi=%d,maxj=%d\n",MAX,maxi,maxj);  
<span style="white-space:pre">			</span>  }    
<span style="white-space:pre">		</span>     if(x[i][j]==MIN)    
<span style="white-space:pre">		</span>{     MIN=x[i][j];    
<span style="white-space:pre">		</span>      mini=i;    
<span style="white-space:pre">		</span>      minj=j;        
<span style="white-space:pre">		</span>      printf("MIN=%d,mini=%d,minj=%d\n",MIN,mini,minj);   
<span style="white-space:pre">		</span> }   
<span style="white-space:pre">	</span>} 
}

05-24 2万+
12-04 1254
03-15 1326
09-25 1万+
05-19 2298
09-27 1万+
11-18 202
07-28 3587
12-15 1923
09-12 3331
11-27 445
12-04 398
04-04 4万+
08-15 8512