大家来查一查我程式错误
给我的错误讯息是“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";
}