| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2909 人关注过本帖
标题:本人自学两天,编了个小程序,不知道什么地方错了。
取消只看楼主 加入收藏
hengmeile
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-7-16
结帖率:0
收藏
已结贴  问题点数:20 回复次数:1 
本人自学两天,编了个小程序,不知道什么地方错了。
是输入一堆数,找最大值的程序
compile 可以通过,但运行时只输了一个数就停止了



#include <stdlib.h>
#include <stdio.h>

#define YES 1
#define NO 0
#define MAX 12000

int array[MAX];
int count ;
int ctr = YES;
int largest(int num_array[],int length);
void continue_function(void);
void input_function(void);

int main(void)
{
      count = 0;
      printf("This program finds the largest number you entered.");
      do
      {
         input_function();
         continue_function();
         count++;
      }while (ctr == YES);
      printf("\nThe largest number you have entered is %d",largest(array,count));

      system("PAUSE");
      return 0;
}

 void input_function(void)
 {
    printf("\nEnter your number:");
    scanf("%d",array[count]);
 }


 void continue_function(void)
 {
    printf("Would you like to continue?");
    do
    {
       printf("Enter 1 to continue or 0 to quit.");
       scanf("%d",ctr);
    }while(ctr != 1&&ctr != 0);


 }

 int largest(int num_array[],int length)
 {
   int biggest = -12000;
   int nbr = 0;
   for(;nbr < length; nbr++)
   {
       if(num_array[nbr]>biggest)
       biggest = num_array[nbr];
   }
   return biggest;
 }
搜索更多相关主题的帖子: 自学 
2010-07-16 00:21
hengmeile
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-7-16
收藏
得分:0 
谢谢了。搞定了。
2010-07-16 14:28
快速回复:本人自学两天,编了个小程序,不知道什么地方错了。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012110 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved