Math.h
返回
math.h
#include
#include
int main(void)
{
double n;
n = sqrt(2.0);
printf("n=%f\n",n);
return 0;
}
/*
運(yùn)行結(jié)果
n=1.414214
*/
#include
#include
int main(void)
{
double n;
n = pow(4.0,4.0);
printf("n: %f\n", n);
return 0;
}
/*
運(yùn)行結(jié)果
n: 256.000000
*/
#include
#include
int main(void)
{
double a,b;
b = modf(123.345, &a);
printf("a = %f\n", a);
printf("b = %f\n", b);
return 0;
}
/*
運(yùn)行結(jié)果
a = 123.000000
b = 0.345000
*/
#include
#include
int main(void)
{
double asin(double x);
double acos(double y);
double d;
d = asin(0.5) / 3.14159 * 180.0;
printf("d = %f\n",d);
d = acos(0.866) / 3.14159 * 180.0;
printf("d = %f\n",d);
return 0;
}
/*
運(yùn)行結(jié)果
d = 30.000025
d = 30.002936
*/
// math.h, ceil
#include
#include
int main(void)
{
int intd;
intd = ceil(13.88);
printf("intd=%d\n",intd);
intd = ceil(-13.88);
printf("intd=%d\n",intd);
return 0;
}
/*
運(yùn)行結(jié)果
intd=14
intd=-13
*/
math.h exp,fabs,floor fmod
#include
#include
int main(void)
{
double d;
d = exp(1.0);
printf("e=%f\n",d);
d = exp(2.0);
printf("e=%f\n",d);
d = exp(3.0);
printf("e=%f\n",d);
d = exp(4);
printf("e=%f\n",d);
d = fabs(-888.8);
printf("d=%f\n",d);
return 0;
}
/*
運(yùn)行結(jié)果1(printf錯(cuò)誤)
printf("e=%d\n",d);
e=-1961601175
e=-1194009170
運(yùn)行結(jié)果2
e=2.718282
e=7.389056
e=20.085537
e=54.598150
d=888.800000
*/
#include
#include
int main(void)
{
int d;
double d1;
d = floor(8888.88);
printf("d=%d\n",d);
d = floor(-8888.88);
printf("d=%d\n",d);
d1 = fmod(100,3);
printf("d1=%f\n",d1);
return 0;
}
/*
運(yùn)行結(jié)果
d=8888
d=-8889
d1=1.000000
*/
math.h,atan
#include
#include
int main(void)
{
double atan(double x);
double atan2(double y, double x);
double d;
d = atan(0.577) / 3.14159 * 180.0;
printf("d = %f\n",d);
d = atan2(0.577, 1.0 ) / 3.14159 * 180.0;
printf("d = %f\n",d);
return 0;
}
/*
運(yùn)行結(jié)果
d = 29.984971
d = 29.984971
*/
指數(shù)分解,math.h frexp
#include
#include
int main(void)
{
double x;
int p;
x = frexp(20.0, &p);
printf("x=%f p=%i\n",x,p);
return 0;
}
/*
運(yùn)行結(jié)果
x=0.625000 p=5
0.625*(2**5) = 20.0
*/
#include
#include
int main(void)
{
double d;
d = log(2.718282);
printf("d=%f\n",d);
d = log10(1000);
printf("d=%f\n",d);
return 0;
}
/*
運(yùn)行結(jié)果
d=1.000000
d=3.000000
*/
返回
巫溪县|
冕宁县|
彰武县|
太和县|
怀柔区|
湾仔区|
西城区|
留坝县|
汉寿县|
沂源县|
闵行区|
巍山|
屯昌县|
阳高县|
拉孜县|
肇东市|
玛多县|
邓州市|
介休市|
深圳市|
阿巴嘎旗|
宁晋县|
商水县|
徐水县|
景德镇市|
金秀|
林口县|
大关县|
苏尼特左旗|
垫江县|
正镶白旗|
海丰县|
麻栗坡县|
三都|
喀喇|
二连浩特市|
宁乡县|
大足县|
合水县|
佛学|
五寨县|