1、创建一个函数,返回元素个数为n的int型数组中的最小值
#include <stdio.h>
#define NUMBER 7
int func1(const int x[], int y)
{
int i, min = x[0];
for (i = 0; i < y; i++)
{
if (x[i] < min)
min = x[i];
}
return min;
}
int main(void)
{
int i, a[NUMBER];
puts("please input the elements.");
for (i = 0; i < NUMBER; i++)
{
printf("a[%d] = ", i); scanf("%d", &a[i]);
}
printf("the min is: %d\n", func1(a, NUMBER));
return 0;
}