I want to achieve this cube root function, my code is as follows:
#include
#include
#include
using namespace std;
class MyMath
{
public:
unsigned long int Square(int target,int k);
unsigned long int Factorial(int n);
double SquareRoot(double n);
double CubeRoot(double n);
};unsigned long int MyMath::Square(int target,int k)
{
unsigned long int result=1;
for (int i=1;i<=k;i++) result*=target;
return result;
}
unsigned long int MyMath::Factorial(int n)
{
if(n==1) return 1;
else return Factorial(n-1)*n;
}
double MyMath::SquareRoot(double n)
{
return sqrt((double)n);
}
double MyMath::CubeRoot(double n)
{
/*return pow((double)n,3);*/
/*
For example, enter 27 the cube root of the result returned after 3.
*/
}
int main()
{
MyMath mm;
int n;
cout<<"please input a integer number:";
cin>>n;
cout< cout< cout< cout< //cout<
return 0;
}
Regards
Ken.
Thank you. :)

VulpesPosted Oct 9, 2013, 9:50 AM
Ken HPosted Oct 9, 2013, 6:46 PM