| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2541 人关注过本帖
标题:这个程序为何在 dev-cpp 通不过,而在 vc6.0 下能通过
只看楼主 加入收藏
lzb6689
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2007-11-9
结帖率:50%
收藏
 问题点数:0 回复次数:7 
这个程序为何在 dev-cpp 通不过,而在 vc6.0 下能通过
以下是dev-cpp环境
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
    double h,l,w,z,x,y,d;
    int i,n,m;
    printf("输入评分个数=");
    scanf("%d",&n);
    if(n<2)return 0;
    y=10000000.0;
    l=y+1;h=-y-1;
    w=0;m=0;
    for(i=1;i<=n;i++)
    {
        //printf("\n");
        printf("%d\n",i);
        scanf("%lf",&x);
        if(x<l)
        {
            if(l>y)
            {
                l=x;
            }
            else
            {
                w+=l;l=x;m++;
            }
        }
        if(x>h)
        {
            if(h<-y)
            {
                h=x;
            }
            else
            {
                w+=h;h=x;m++;
            }
        }
        if((x>=l)&&(x<=h))
        {
            w+=x;m++;
        }
    }
    if(m>0)w=w/m;
    printf("w=%16.16f\n",w);
    system("pause");   
    return 0;
}
编译后显示:
  d:\My Documents\C-Free\Projects\c31\Makefile.win [Error] [工程1.exe] Error 1 (if this is the only error: please check your library includes)



[ 本帖最后由 lzb6689 于 2014-9-11 18:03 编辑 ]
搜索更多相关主题的帖子: return double include 
2014-09-11 18:02
lzb6689
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2007-11-9
收藏
得分:0 
vc6.0下:
// c6.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
        double h,l,w,z,x,y,d;
    int i,n,m;
    printf("输入评分个数=");
    scanf("%d",&n);
    if(n<2)return 0;
    y=10000000.0;
    l=y+1;h=-y-1;
    w=0;m=0;
    for(i=1;i<=n;i++)
    {
        //printf("\n");
        printf("%d\n",i);
        scanf("%lf",&x);
        if(x<l)
        {
            if(l>y)
            {
                l=x;
            }
            else
            {
                w+=l;l=x;m++;
            }
        }
        if(x>h)
        {
            if(h<-y)
            {
                h=x;
            }
            else
            {
                w+=h;h=x;m++;
            }
        }
        if((x>=l)&&(x<=h))
        {
            w+=x;m++;
        }
    }
    if(m>0)w=w/m;
    printf("w=%16.16f\n",w);

    return 0;
}
编译后:c6.exe - 0 error(s), 2 warning(s)
2014-09-11 18:04
zklhp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:china
等 级:贵宾
威 望:254
帖 子:11485
专家分:33241
注 册:2007-7-10
收藏
得分:0 
代码没问题 不知道是不是你的编译环境的问题

提示可能有帮助

if this is the only error: please check your library includes

如果这是唯一的错误 请检测你的库引用
2014-09-11 18:17
erty1001
Rank: 9Rank: 9Rank: 9
等 级:蜘蛛侠
威 望:4
帖 子:331
专家分:1433
注 册:2014-8-31
收藏
得分:0 
简单说说:
多数VC6.0 版本没有#include "stdafx.h"
2014-09-11 20:04
vvvcuu
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:12
帖 子:353
专家分:1253
注 册:2014-4-22
收藏
得分:0 
两者使用的编译器不同,拥有不同的头文件和预定义。所以有差别。

VC系列和VS系列都是微软出品的编译器,里面的很多东西都是微软自定义的,与标准C(ANSI C,C89,C99等)差别还是很明显的,相对来说gcc编译器对标准C的兼容性要好得多。

如果打算开发Windows下的程序或者非跨平台的程序,VS系列的IDE绝对是很好的开发环境。不过,如果想跨平台的话,那么经常使用VS则容易被微软绑架,因为VS中的很多东西在其它编译器下是没法使用的。

代码测试环境:  WinXP+C-Free5.0.
2014-09-11 22:02
ctl184762651
Rank: 1
等 级:新手上路
帖 子:56
专家分:0
注 册:2014-5-31
收藏
得分:0 
关于这个 while 为何会循环打印 2 次
程序代码:
#include<stdio.h>
int main(void)
{   
int guess=1;
printf("Uh..is your number %d?\n",guess); 

    while(getchar()!='y')
    
    printf("Well,then,is it %d?\n",guess++);

printf("i konw i could do it\n");

return 0;
} 

首先打印Uh..is your number 1
然后要求输入,如果等于Y,打印i konw i could do it
如果等于N,打印Well,then,is it %d?
假如如下
Uh..is your number 1?
键入n
Well,then,is it 2?
n
Well,then,is it 3?
y
i konw i could do it
这个是预期结果,可是为什么每次输入N后就连续打印2次
Well,then,is it 2?
Well,then,is it 3?
n
Well,then,is it 4?
Well,then,is it 5?
2014-09-11 23:03
ctl184762651
Rank: 1
等 级:新手上路
帖 子:56
专家分:0
注 册:2014-5-31
收藏
得分:0 
发错了
2014-09-11 23:06
lzb6689
Rank: 1
等 级:新手上路
帖 子:46
专家分:0
注 册:2007-11-9
收藏
得分:0 
谢谢zklhp,的确与编译环境有关,我在另一台电脑上用dev-c++顺利编译通过,一点问题也没有。
2014-09-12 17:46
快速回复:这个程序为何在 dev-cpp 通不过,而在 vc6.0 下能通过
数据加载中...
 
   



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

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