更新时间:2022-08-12 16:31:05
#include <syslib.h> #include <math.h> int main(){ int x = -5; printf("|%d|=%d\n",x,abs(x)); x=0; printf("|%d|=%d\n",x,abs(x)); x=+5; printf("|%d|=%d\n",x,abs(x)); getchar(); return 0; }
#include <syslib.h> #include <math.h> int main(){ float x; x=0.32; printf("acos(%.2f)=%.4f",x,acos(x)); getchar(); return 0; }
asin
原 型:extern float asin(float x);#include <syslib.h> #include <math.h> int main(){ float x; x=0.32; printf("asin(%.2f)=%.4f",x,asin(x)); getchar(); return 0; }
#include <syslib.h> #include <math.h> int main(){ float x; x=0.32; printf("atan(%.2f)=%.4f",x,atan(x)); getchar(); return 0; }
atan2
原 型:extern float atan2(float y, float x);#include <syslib.h> #include <math.h> int main() { float x,y; x=0.064; y=0.2; printf("atan2(%.3f,%.2f)=%.4f",y,x,atan2(y,x)); getchar(); return 0; }
ceil
原型:extern float ceil(float x);#include <syslib.h> #include <math.h> int main() { float x; x=74.12; printf("ceil(%.2f)=%.0f\n",x,ceil(x)); x=-74.12; printf("ceil(%.2f)=%.0f\n",x,ceil(x)); getchar(); return 0; }
cos
原 型:extern float cos(float x);#include <syslib.h> #include <math.h> int main(){ float x; x=PI/4.; printf("cos(%.4f)=%.4f\n",x,cos(x)); getchar(); return 0; }
#include <syslib.h> #include <math.h> int main(){ float x; x=PI/4.; printf("cosh(%.4f)=%.4f\n",x,cosh(x)); getchar(); return 0; }
exp
原 型:extern float exp(float x);#include <syslib.h> #include <math.h> int main(){ printf("e=%f\n",exp(1.0)); getchar(); return 0; }
#include <syslib.h> #include <math.h> int main(){ float x; x=-74.12; printf("|%f|=%f\n",x,fabs(x)); x=0; printf("|%f|=%f\n",x,fabs(x)); x=74.12; printf("|%f|=%f\n",x,fabs(x)); getchar(); return 0; }
#include <syslib.h> #include <math.h> int main() { float x; x=74.12; printf("floor(%.2f)=%.0f\n",x,floor(x)); x=-74.12; printf("floor(%.2f)=%.0f\n",x,floor(x)); getchar(); return 0; }
#include <syslib.h> #include <math.h> int main(){ float x,y; x=74.12; y=6.4; printf("74.12/6.4: %f\n",fmod(x,y)); x=74.12; y=-6.4; printf("74.12/(-6.4): %f\n",fmod(x,y)); getchar(); return 0; }
#include <syslib.h> #include <math.h> int main(){ float x; int exp; textmode(0x00); x=frexp(64.0,&exp); printf("64=%.2f*2^%d",x,exp); getchar(); return 0; }
#include <syslib.h> #include <math.h> int main(){ printf("3^2+4^2=%.0f^2\n",hypot(3.,4.)); printf("3.2^2+4.3^2=%.2f^2",hypot(x,y)); getchar(); return 0; }
#include <syslib.h> #include <math.h> int main(){ float x; printf("ln(e)=%f\n", log(x)); getchar(); return 0; }
#include <syslib.h> #include <math.h> int main(){ float x; printf("lg(5)=%f\n", log10(5.0)); getchar(); return 0; }
#include <syslib.h> #include <math.h> int main(){ float x, i; x=modf(-74.12,&i); printf("-74.12=%.0f+(%.2f)",i,x); getchar(); return 0; }
pow10
原 型:extern float pow10(float x);#include <syslib.h> #include <math.h> int main(){ printf("10^3.2=%f\n",pow10(3.2)); printf("10^3.2=%f",pow(10,3.2)); getchar(); return 0; }
#include <syslib.h> #include <math.h> main(){ printf("4^5=%f",pow(4.,5.)); getchar(); return 0; }
sin
原 型:extern float sin(float x);#include <syslib.h> #include <math.h> int main(){ float x; x=M_PI/2; printf("sin(PI/2)=%f",sin(x)); getchar(); return 0; }
#include <syslib.h> #include <math.h> int main(){ printf("sqrt(2000)=%f",sqrt(2000.0)); getchar(); return 0; }
tan
原 型:extern float tan(float x);#include <syslib.h> #include <math.h> int main(){ float x; x=M_PI/4; printf("tan(PI/4)=%f",tan(x)); getchar(); return 0; }