求出二维数组a[ ][5]={34,3,25,75,48.45,234,32,421,1.33,23,32,43,53.76,7,78,89,56.75,65,32,53,17
问题描述:
求出二维数组a[ ][5]={34,3,25,75,48.45,234,32,421,1.33,23,32,43,53.76,7,78,89,56.75,65,32,53,17
}每一行中的最小值和最大值并存入一个数组b中,b数组中每行有两个元素,第一个元素是最小值,第二个元素是最大值.
答
#include
void get_max_min( float a[5] , float b[2] )
{
int i=0;
b[0]=b[1]=a[0];
for( i=1; i{
printf("%.2lf " , a[i-1] );
if ( b[1]else
if ( b[0]>a[i] ) b[0]=a[i] ;
}
printf("%.2lf\n" , a[i-1] );
printf("min=%.2lf max=%.2lf\n" , b[0] , b[1] );
}
int main()
{
float a[][5]={34,3,25,75,48.45,234,32,421,1.33,23,32,43,53.76,7,78,89,56.75,65,32,53,17};
float b[10][2]={{0,0}};
int i=0;
for( i=0;i
return 0;
}