| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 469 人关注过本帖
标题:[求助]哪位请指点一下我错在哪里,谢谢!
只看楼主 加入收藏
anoldyan
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2007-9-11
收藏
 问题点数:0 回复次数:5 
[求助]哪位请指点一下我错在哪里,谢谢!

我是初学者,安装了dev c++的开发工具,但是使用起来偶尔会出问题。即按照书本的案例编写的程序,仔细检查了几遍,和书上的一样,但是运行时仍会提示错误,该如何是好?

#include <iostream>

int Doubler(int AmountToDouble);

int main()
{
using std::cout;

int result = 0;
int input;

cout << "Enter a number between 0 and 10,000 to double:";
std::cin >> input;

cout << "\nBefore doubler is called...";
cout << "\ninput:" << input << " doubled:" << result << "\n";

result = Doubler(input);

cout << "\Back from Doubler...\n";
cout << "\ninput:" << input << " doubled:" << result << "\n";
char response;
std::cin>>response;
return 0;
}

int Double(int original)
{
if (original <= 10000)
return original * 2;
else
return -1;
std::cout << "You can't get here!\n";
}

2007-11-01 22:22
aipb2007
Rank: 8Rank: 8
来 自:CQU
等 级:贵宾
威 望:40
帖 子:2879
专家分:7
注 册:2007-3-18
收藏
得分:0 
result = Doubler(input);
int Double(int original)

函数名不一样

函数应该有前向声明

应该有 <iostream>

Fight  to win  or  die...
2007-11-01 22:36
yuyunliuhen
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1435
专家分:0
注 册:2005-12-12
收藏
得分:0 

你哪炒错了吧?、
#include <iostream>

int Doubler(int AmountToDouble);


int main()
{
using std::cout;

int result = 0;
int input;

cout << "Enter a number between 0 and 10,000 to double:";
std::cin >> input;

cout << "\nBefore doubler is called...";
cout << "\ninput:" << input << " doubled:" << result << "\n";

result = Doubler(input);

cout << "\nBack from Doubler...\n";
cout << "\ninput:" << input << " doubled:" << result << "\n";
char response;
std::cin>>response;
return 0;
}

int Doubler(int original)
{
if (original <= 10000)
return original * 2;
else
return -1;
std::cout << "You can't get here!\n";
}


Go confidently in the  directions of your dreams,live the life you have imagined!Just do it!
It is no use learning without thinking!
2007-11-01 22:38
yuyunliuhen
Rank: 6Rank: 6
等 级:贵宾
威 望:20
帖 子:1435
专家分:0
注 册:2005-12-12
收藏
得分:0 
  好像迟了

Go confidently in the  directions of your dreams,live the life you have imagined!Just do it!
It is no use learning without thinking!
2007-11-01 22:39
aipb2007
Rank: 8Rank: 8
来 自:CQU
等 级:贵宾
威 望:40
帖 子:2879
专家分:7
注 册:2007-3-18
收藏
得分:0 


嘿嘿

Fight  to win  or  die...
2007-11-01 22:45
anoldyan
Rank: 1
等 级:新手上路
帖 子:28
专家分:0
注 册:2007-9-11
收藏
得分:0 
好像是我抄错了。谢谢两位的指点。
2007-11-02 16:37
快速回复:[求助]哪位请指点一下我错在哪里,谢谢!
数据加载中...
 
   



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

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