zhuluo3420
幼苗
共回答了17个问题采纳率:88.2% 举报
#include
#include
float sqrsum(int *array,int row,int col)
{
int max = array[0];
int min = array[0];
float result = 0.0f;
int i;
int j;
for(i = 0; i < row; i++)
{
for(j = 0; j < col; j++)
{
if(max < array[i * col + j])
{
max = array[i * col + j];
}
if(min > array[i * col + j])
{
min = array[i * col + j];
}
}
}
result = sqrt(max) + sqrt(min);
return result;
}
int main(void)
{
int arr1[][4] = { {11,33,56,67},
{45,43,54,69},
{96,73,68,79},
{25,45,86,91}
};
int arr2[][3] = {{23,45,56},
{34,74,85},
{56,98,56},
{98,54,83},
{33,87,74},
{13,66,53}};
float pa;
float pb;
pa = sqrsum((int*)arr1,4,4);
pb = sqrsum((int*)arr2,6,3);
printf("pa + pb = %.5fn",pa + pb);
return 0;
}
1年前
8