| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 482 人关注过本帖
标题:大家来查一查我程式错误
取消只看楼主 加入收藏
suckdog
Rank: 1
等 级:新手上路
帖 子:130
专家分:0
注 册:2007-9-19
结帖率:41.67%
收藏
 问题点数:0 回复次数:0 
大家来查一查我程式错误
给我的错误讯息是“Warning W8013 295#9.cpp 22: Possible use of 'p' before definition in function main()
Warning W8013 295#9.cpp 22: Possible use of 'o' before definition in function main()
教我一下如何修正, 谢谢

#include <iostream>
using namespace std;
void getnum (int pound, int ounces);
double calculatepoundtokilogram (int pound);
double calculateouncestogram(int ounces);
void returnanswer(double kilogram, double gram, int pound, int ounces);

main()
{
int p, o;
double kg, g;
char choice;

do
{
getnum (p, o);
kg=calculatepoundtokilogram(p);
g=calculateouncestogram(o);
returnanswer(kg, g, p, o);
cout<<"Again?\n";
cin>>choice;
}while (choice=='y' || choice=='Y');

return 0;
}

void getnum (int pound, int ounces)
/*****************************************************************************************
Name: getnum
Purpose : get amount of pound and ounces
Arguments:
Return Value: none
*****************************************************************************************/
{
cout<<"Enter amount of pounds:\n";
cin>>pound;
cout<<"Enter amount of ounces:\n";
cin>>ounces;
}

double calculatepoundtokilogram (int pound)
/*****************************************************************************************
Name: calculatepoundtokilogram
Purpose : convert pound to kilogram
Arguments:
Return Value: kg
*****************************************************************************************/
{
double kg;
kg=pound/2.2046;
return kg;
}

double calculateouncestogram(int ounces)
/*****************************************************************************************
Name: calculateouncestogram
Purpose : convert ounces to gram
Arguments:
Return Value: g
*****************************************************************************************/
{
double g;
g=ounces/16/2.2046;
return g;
}

void returnanswer(double kilogram, double gram, int pound, int ounces)
/*****************************************************************************************
Name: returnanswer
Purpose : return answer
Arguments:
Return Value: none
*****************************************************************************************/
{
cout<<"There are "<<kilogram<<" kilogram in "<<pound<<" pound.\n";
cout<<"There are "<<gram<<" gram in "<<ounces<<" ounces.\n";
}
搜索更多相关主题的帖子: int 程式 double pound definition 
2007-10-31 02:39
快速回复:大家来查一查我程式错误
数据加载中...
 
   



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

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