1、头文件
和。
2、测试
#include
#include
using namespace std;
int main()
{
int iTemp = 0;
double dTemp = 0;
cout << "幂函数 " << setw(25) << " pow(2, 2) = " << pow(2, 2) << endl;
cout << "指数函数 " << setw(20) << " exp(2) = " << exp(2) << endl;
cout << "平方根 " << setw(23) << " sqrt(4) = " << sqrt(4) << endl;
cout << "自然对数 " << setw(20) << " log(1) = " << log(1) << endl;
cout << "以10为底的对数 " << setw(17) << " log10(10) = " << log10(10) << endl;
cout << "向上取整 " << setw(23) << " ceil(3.6) = " << ceil(3.6) << endl;
cout << "向下取整 " << setw(24) << " floor(3.6) = " << floor(3.6) << endl;
cout << "浮点数的绝对值 " << setw(18) << " fabs(-3.6) = " << fabs(-3.6) << endl;
cout << "浮点数相除的余数 " << setw(19) << " fmod(3.7,1.8) = " << fmod(3.7,1.8) << endl;
cout << "3.6 = 返回值 * 2^itemp " << setw(33) << " frexp(3.6, &iTemp) = " << frexp(3.6, &iTemp) << ends;
cout << "iTemp = " << iTemp << endl;
cout << "将浮点数乘以2的某个整数次幂 " << setw(21) << " ldexp(2,3) = " << ldexp(2,3) << endl;
cout << "将浮点数分离为带正负号的整数和小数 " << setw(20) << " modf(3.6, &dTemp) = " << modf(-3.6, &dTemp) << ends;
cout << "dTemp = " << dTemp << endl;
cout << "求 int 的绝对值 " << setw(17) << " abs(-3) = " << abs(-3) << endl;
cout << "求 long的绝对值 " << setw(20) << " labs(-3.6) = " << labs(-3.6) << endl;
cout << "求 long long 的绝对值 " << setw(15) << " llabs(-3.6) = " << llabs(-3.6) << endl;
//cout << "求 int 相除的商和余 = " << div(3,1) << endl;
//cout << "求 long 相除的商和余 = " << ldiv(3.6,1.0) << endl;
//cout << "求 long long 相除的商和余 = " << lldiv(3.6,1.0) << endl;
cout << "正弦 " << setw(28) << " sin(60) = " << sin(60) << endl;
cout << "余弦 " << setw(28) << " cos(30) = " << cos(30) << endl;
cout << "正切 " << setw(28) << " tan(1) = " << tan(1) << endl;
cout << "双曲正弦 " << setw(25) << " sinh(60) = " << sinh(60) << endl;
cout << "双曲余弦 " << setw(25) << " cosh(30) = " << cosh(30) << endl;
cout << "双曲正切 " << setw(24) << " tanh(1) = " << tanh(1) << endl;
cout << "反正弦 " << setw(27) << " asin(60) = " << asin(60) << endl;
cout << "反余弦 " << setw(27) << " acos(30) = " << acos(30) << endl;
cout << "反正切 " << setw(26) << " atan(1) = " << atan(1) << endl;
//cout << "商的反正切 = " << atan2(1) << endl;
cout << "反双曲正弦 " << setw(24) << " asinh(60) = " << asinh(60) << endl;
cout << "反双曲余弦 " << setw(24) << " acosh(30) = " << acosh(30) << endl;
cout << "反双曲正切 " << setw(23) << " atanh(1) = " << atanh(1) << endl;
system("pause");
}
//结果
//幂函数 pow(2, 2) = 4
//指数函数 exp(2) = 7.38906
//平方根 sqrt(4) = 2
//自然对数 log(1) = 0
//以10为底的对数 log10(10) = 1
//向上取整 ceil(3.6) = 4
//向下取整 floor(3.6) = 3
//浮点数的绝对值 fabs(-3.6) = 3.6
//浮点数相除的余数 fmod(3.7, 1.8) = 0.1
//3.6 = 返回值 * 2 ^ itemp frexp(3.6, &iTemp) = 0.9 iTemp = 2
//将浮点数乘以2的某个整数次幂 ldexp(2, 3) = 16
//将浮点数分离为带正负号的整数和小数 modf(3.6, &dTemp) = -0.6 dTemp = -3
//求 int 的绝对值 abs(-3) = 3
//求 long的绝对值 labs(-3.6) = 3
//求 long long 的绝对值 llabs(-3.6) = 3
//正弦 sin(60) = -0.304811
//余弦 cos(30) = 0.154251
//正切 tan(1) = 1.55741
//双曲正弦 sinh(60) = 5.71004e+25
//双曲余弦 cosh(30) = 5.34324e+12
//双曲正切 tanh(1) = 0.761594
//反正弦 asin(60) = -nan(ind)
//反余弦 acos(30) = -nan(ind)
//反正切 atan(1) = 0.785398
//反双曲正弦 asinh(60) = 4.78756
//反双曲余弦 acosh(30) = 4.09407
//反双曲正切 atanh(1) = inf
//请按任意键继续. . .
作者:Liu_Xiao_Ming