大家帮忙看下这个程序出什么问题了!
#include <iostream>
#include <conio.h>
using std::cin;
using std::cout;
using std::endl;
double Mass(double T,double R);
double Power(double X,int n);
int main(void)
{
double T;
double R;
cout << "请输入周期:";
cin >> T;
cout << "请输入轨道半径:";
cin >> R;
cout << "中心天体的质量为\"" <<Mass(T,R) << ".";
cout << endl
<< "press any key. . .";
_getch();
return 0;
}
double Mass(double T,double R)
{
double reasult;
double G = 6.67 * Power(10,-11);
reasult = ( (4 * Power(3.14,2) * Power(R,3) ) ) / (G * Power(T,2));
return reasult;
}
double Power(double X,int n)
{
double reasult;
if(n < 0)
{
X = 1/X;
n = -n;
}
if(n > 0)
{
reasult = X * Power(X,n-1);
}
else
return 1.0;
return reasult;
}
为什么会出现这样的结果,有什么解决方法吗?