?? main.cpp
字號:
#include "means.h"
using namespace std;
void main()
{
long double x,t1,t2;
int n,digit,flag; //digit為需要達到的精度,即小數點后多少位
cout<< "1:求ln(x); 2:求x^(1/n); 3:quit " <<endl;
cin>>flag;
while(flag==1||flag==2)
{
if(flag==1)
{
cout<<"input x:"<<endl;
cin>>x;
cout<<"input the precision you want:"<<endl;
cin>>digit;
TLargeFloat::TDigits sCount(digit);
TLargeFloat ln_result(0.0,sCount);
t1 = (double)clock();
ln_result=OP_ln(x,digit);
t2 = (double)clock();
cout<<"計算所花時間為: "<<t2-t1<<"ms"<<endl;
cout<<"計算所得結果為:";
Debug_toCout("ln(x)=",ln_result);
cout<<setprecision(20);
cout<<"利用VC自帶數學函數求得的結果為:"<<endl;
cout<<log(x)<<endl<<endl;
cout<< "1:求ln(x); 2:求x^(1/n); 3:quit " <<endl;
cin>>flag;
}
else
{
cout<<"input x:"<<endl;
cin>>x;
cout<<"input n:"<<endl;
cin>>n;
cout<<"input the precision you want:"<<endl;
cin>>digit;
TLargeFloat::TDigits sCount(digit);
TLargeFloat PowerRoot(0.0,sCount);
t1 = (double)clock();
PowerRoot=OP_PowerRoot(x,n,digit);
t2 = (double)clock();
cout<<"計算所花時間為: "<<t2-t1<<"ms"<<endl;
cout<<"計算所得結果為:";
Debug_toCout("x^(1/n)==",PowerRoot);
cout<<setprecision(20);
cout<<"利用VC自帶數學函數求得的結果為:"<<endl;
cout<<pow(x,1.0/n)<<endl<<endl;
cout<< "1:求ln(x); 2:求x^(1/n); 3:quit " <<endl;
cin>>flag;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -