#include <stdio.h>
int find_max_in(int M, int arr[10])
{
int i = 0;
int max = arr[0];
int min = arr[0];
for (i = 0; i < M; i++)
{
if (max < arr[i])
{
max = arr[i];
}
if (min > arr[i])
{
min = arr[i];
}
}
return max - min;
}
int main()
{
int M = 0;
int arr[10];
scanf_s("%d", &M);
int i = 0;
for (i = 0; i < M; i++)
{
scanf_s("%d",&arr[i]);
}
printf("%d", find_max_in(M, arr));
}
C语言自定义函数找最大值和最小值
最新推荐文章于 2024-09-04 21:39:45 发布