
文章目錄
- 1. acos
- 2. asin
- 3. atan
- 4. atan2
- 5. cos
- 6. cosh
- 7. sin
- 8. sinh
- 9. tan
- 10. tanh
- 11. exp
- 12. frexp
- 13. ldexp
- 14. log
- 15. log10
- 16. modf
- 17. pow
- 18. sqrt
- 19. ceil
- 20. fabs
- 21. floor
- 22. fmod
1. acos
double acos(double x);
作用: 回傳以弧度表示的 x 的反余弦,(-Π~Π)
#include<stdio.h>
#include<math.h>
#define PI acos(-1)
int main()
{
printf("%lf度",acos(1)*180/PI);
return 0;
}

2. asin
double asin(double x);
作用: 回傳以弧度表示的 x 的反正弦,(-Π~Π)
#include<stdio.h>
#include<math.h>
#define PI acos(-1)
int main()
{
printf("%lf度",asin(1)*180/PI);
return 0;
}

3. atan
double atan(double x);
作用: 回傳以弧度表示的 x 的反正切,(-Π/2~Π/2)
#include<stdio.h>
#include<math.h>
#define PI acos(-1)
int main()
{
printf("%lf度",atan(0)*180/PI);
return 0;
}

4. atan2
double atan2(double y, double x);
作用: 回傳以弧度表示的 y/x 的反正切,y 和 x 的值的符號決定了正確的象限,
#include<stdio.h>
#include<math.h>
#define PI acos(-1)
int main()
{
printf("%lf度",atan2(7,-7)*180/PI);
return 0;
}

5. cos
double cos(double x);
作用: 回傳弧度角 x 的余弦,
#include<stdio.h>
#include<math.h>
#define PI acos(-1)
int main()
{
printf("%lf",cos(PI));
return 0;
}

6. cosh
double cosh(double x);
作用: 回傳 x 的雙曲余弦,
#include<stdio.h>
#include<math.h>
#define PI acos(-1)
int main()
{
printf("%lf",cosh(0.5));
return 0;
}

7. sin
double sin(double x);
作用: 回傳弧度角 x 的正弦,
#include<stdio.h>
#include<math.h>
#define PI acos(-1)
int main()
{
printf("%lf",sin(PI));
return 0;
}

8. sinh
double sinh(double x);
作用: 回傳 x 的雙曲正弦,
#include<stdio.h>
#include<math.h>
#define PI acos(-1)
int main()
{
printf("%lf",sinh(0.5));
return 0;
}

9. tan
double tan(double x);
作用: 回傳弧度角 x 的正切,
#include<stdio.h>
#include<math.h>
#define PI acos(-1)
int main()
{
printf("%lf",tan(PI/4));
return 0;
}

10. tanh
double tanh(double x);
作用: 回傳 x 的雙曲正切,
#include<stdio.h>
#include<math.h>
#define PI acos(-1)
int main()
{
printf("%lf",tanh(0.5));
return 0;
}

11. exp
double exp(double x);
作用: 回傳 e 的 x 次冪的值,
#include<stdio.h>
#include<math.h>
int main()
{
printf("%lf",exp(1));
return 0;
}

12. frexp
double frexp(double x, int *exponent);
作用: 把浮點數 x 分解成尾數和指數,回傳值是尾數,并將指數存入 exponent 中,所得的值是 x = mantissa * 2 ^ exponent,
#include<stdio.h>
#include<math.h>
int main()
{
double x = 1024, fraction;
int e;
fraction = frexp(x, &e);
printf("x = %.2lf = %.2lf * 2^%d\n", x, fraction, e);
return(0);
}

13. ldexp
double ldexp(double x, int exponent);
作用: 回傳 x 乘以 2 的 exponent 次冪,
#include<stdio.h>
#include<math.h>
int main()
{
printf("%lf",ldexp(2,2));
return(0);
}

14. log
double log(double x);
作用: 回傳 x 的自然對數(基數為 e 的對數),
#include<stdio.h>
#include<math.h>
int main()
{
printf("%lf",log(2.7));
return(0);
}

15. log10
double log10(double x);
作用: 回傳 x 的常用對數(基數為 10 的對數),
#include<stdio.h>
#include<math.h>
int main()
{
printf("%lf",log10(100));
return(0);
}

16. modf
double modf(double x, double *integer);
作用: 回傳值為小數部分(小數點后的部分),并設定 integer 為整數部分,
#include<stdio.h>
#include<math.h>
int main()
{
double x, fractpart, intpart;
x = 8.123456;
fractpart = modf(x, &intpart);
printf("整數部分 = %lf\n", intpart);
printf("小數部分 = %lf \n", fractpart);
return(0);
}

17. pow
double pow(double x, double y);
作用: 回傳 x 的 y 次冪,
#include<stdio.h>
#include<math.h>
int main()
{
printf("%lf\n",pow(2,3));
return(0);
}

18. sqrt
double sqrt(double x);
作用: 回傳 x 的平方根,
#include<stdio.h>
#include<math.h>
int main()
{
printf("%lf\n",sqrt(4));
return(0);
}

19. ceil
double ceil(double x);
作用: 回傳大于或等于 x 的最小的整數值,
#include<stdio.h>
#include<math.h>
int main()
{
printf("%lf\n",ceil(4));
printf("%lf\n",ceil(3.5));
return(0);
}

20. fabs
double fabs(double x);
作用: 回傳 x 的絕對值,
#include<stdio.h>
#include<math.h>
int main()
{
printf("%lf\n",fabs(4));
printf("%lf\n",fabs(-3.5));
return(0);
}

21. floor
double floor(double x);
作用: 回傳小于或等于 x 的最大的整數值,
#include<stdio.h>
#include<math.h>
int main()
{
printf("%lf\n",floor(3.5));
printf("%lf\n",floor(-3.5));
return(0);
}

22. fmod
double fmod(double x, double y);
作用: 回傳 x 除以 y 的余數,
#include<stdio.h>
#include<math.h>
int main()
{
printf("%lf\n",fmod(3,2));
printf("%lf\n",fmod(3,3));
return(0);
}

轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/250136.html
標籤:其他
上一篇:Ubuntu20.04LTS(amd64) 下安裝 GTK4
下一篇:寒假不想荒廢,先復習C語言吧!
