注册 登录
编程论坛 新人交流区

大家来查一查我程式错误

suckdog 发布于 2007-10-31 02:39, 490 次点击
给我的错误讯息是“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";
}
3 回复
#2
albert7482007-10-31 08:03
一句注释都没有。。。。看8懂
#3
sky756437932007-10-31 09:55
不明白
#4
nicaiwa2007-10-31 10:03
写的啥哦!
1