当前位置: 代码迷 >> C语言 >> 帮帮小女
  详细解决方案

帮帮小女

热度:445   发布时间:2004-06-09 02:30:00.0
帮帮小女

我刚学的c语言 对这个程序很不了解 谁能帮我每一步都解释一下呢~? 谢谢拉~

/* Passing an array to a function. */

#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));

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  array  count  MAX  

----------------解决方案--------------------------------------------------------

/* Passing an array to a function. */

#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)); /*输出largest函数返回的值*/

return 0; } /* Function largest() returns the largest value */ /* in an integer array */

int largest(int num_array[], int length) /*该函数功能是将num_array数组中的最大值找出并返回*/ { int count, biggest = -12000; /*定义一个biggest变量存放最大值*/

for ( count = 0; count < length; count++) { if (num_array[count] > biggest) /*如果num_array[count] 比biggest还大就将num_array[count] 赋给biggest*/ biggest = num_array[count]; }

return biggest; }


----------------解决方案--------------------------------------------------------
提示: 作者被禁止或删除 内容自动屏蔽
2008-06-02 02:37:38
liyanhong

来 自:水星
等 级:ID已被封
威 望:8
帖 子:1868
专家分:0
注 册:2008-5-3
  得分:0 
人面不知何处去,桃花依旧笑春风
----------------解决方案--------------------------------------------------------
怎么我看到这么乱??
----------------解决方案--------------------------------------------------------
同意楼上的
我这没法看
格式乱乱
----------------解决方案--------------------------------------------------------
人面不知何处 绿波依旧东流......
----------------解决方案--------------------------------------------------------
提示: 作者被禁止或删除 内容自动屏蔽
2008-06-02 10:16:40
xydpf

等 级:新手上路
帖 子:15
专家分:0
注 册:2008-5-9
  得分:0 
太乱了!!
----------------解决方案--------------------------------------------------------
/* Passing an array to a function. */

#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)); /*输出largest函数返回的值*/

return 0;
}
/* Function largest() returns the largest value */
/* in an integer array */

int largest(int num_array[], int length) /*该函数功能是将num_array数组中的最大值找出并返回*/
{
  int count, biggest = -12000; /*定义一个biggest变量存放最大值*/

  for ( count = 0; count < length; count++)
  {
    if (num_array[count] > biggest) /*如果num_array[count] 比biggest还大就将num_array[count] 赋给biggest*/
    biggest = num_array[count];
   }

return biggest;
}
----------------解决方案--------------------------------------------------------
  相关解决方案