第1个回答 2020-06-10
//参考源码
#include <stdio.h>
#define ROW 3
#define COL 4
int calc_min(int *arr, int row, int col)
{
int min;
int *p = arr;
min = arr[0];
while(p < arr+row*col)
{
if(min>*p)
min = *p;
p++;
}
return min;
}
int main()
{
int arr[ROW][COL];
int i,j,min;
printf("Input array element:\n");
for(i=0; i<ROW; i++)
for(j=0; j<COL; j++)
scanf("%d", &arr[i][j]);
printf("\nOutput array element:\n");
for(i=0; i<ROW; i++){
for(j=0; j<COL; j++)
printf("%d ", arr[i][j]);
printf("\n");
}
min = calc_min(arr[0], ROW, COL);
printf("min value: %d\n", min);
return 0;
}
测试用例:
F:\c_work>a.exe
Input array element:
4 6 8 9
12 6 24 81
98 64 -88 15
Output array element:
4 6 8 9
12 6 24 81
98 64 -88 15
min value: -88本回答被网友采纳