- 论坛徽章:
- 0
|
#include <stdio.h>
#define MAX 10
int array[MAX], count;
int largest(int num_array[], int length);
int main( void )
{
/* Input MAX values from the keyboard. */
for (count = 0; count < MAX; count++)
{
printf("Enter an integer value: ");
scanf("%d", &array[count]);
}
/* Call the function and display the return value. */
printf("\n\nLargest value = %d\n", largest(array, MAX));
system("PAUSE");
return 0;
}
/* Function largest() returns the largest value */
/* in an integer array */
int largest(int num_array[], int length)
{
int count, biggest = -12000;
for ( count = 0; count < length; count++)
{
if (num_array[count] > biggest)
biggest = num_array[count];
}
return biggest;
}
这是一个将数组传递给函数的例子,我想问一下这其中的 int length 这个length的值是怎么得到的啊?这之前好像也没有赋值,哪位高手能给解释一下嘛?
[ 本帖最后由 fuyic 于 2008-11-26 16:51 编辑 ] |
|