C++常用的系统函数
數(shù)學(xué)<math.h>:
1 三角函數(shù)
double sin (double);
double cos (double);
double tan (double);
2 反三角函數(shù)
double asin (double); 結(jié)果介于[-PI/2, PI/2]
double acos (double); 結(jié)果介于[0, PI]
double atan (double); 反正切(主值), 結(jié)果介于[-PI/2, PI/2]
double atan2 (double, double); 反正切(整圓值), 結(jié)果介于[-PI/2, PI/2]
3 雙曲三角函數(shù)
double sinh (double);
double cosh (double);
double tanh (double);
4 指數(shù)與對數(shù)
double exp (double x); e的x次冪
double pow (double x, double y); x的y次冪
double sqrt (double);
double log (double x); 以e為底的對數(shù),即ln x
double log10 (double x);log10(x) 以10為底。
沒有以2為底的函數(shù)但是可以用換底公式解 決:log2(N)=log10(N)/log10(2)
5 取整
double ceil (double); 不小于x的最小整數(shù)
double floor (double); 不大于x的最大整數(shù)
6 絕對值
int abs(int);整型
long labs(long);長整型
double fabs (double);浮點(diǎn)型
7 標(biāo)準(zhǔn)化浮點(diǎn)數(shù)
double frexp (double f, int p); 標(biāo)準(zhǔn)化浮點(diǎn)數(shù), f = x 2^p, 已知f求x, p ( x介于[0.5, 1] )
double ldexp (double x, int p); 與frexp相反, 已知x, p求f
8 取整與取余
double modf (double, double*); 將參數(shù)的整數(shù)部分通過指針回傳, 返回小數(shù)部分
double fmod (double, double); 返回兩參數(shù)相除的余數(shù)
9.平方根
double sqrt(double x);
字符<ctype.h>:
int isalpha(int c);c是否為字母
int isdigit(int c);c是否為數(shù)字
int tolower(int c);將c轉(zhuǎn)換為小寫字母
int toupper(int c);將c轉(zhuǎn)換為大寫字母
字符串<string.h>:
char strcpy(char sl,char s2);將字符串s2復(fù)制給s1,即覆蓋
unsigned strlen(char sr);求字符串str長度
內(nèi)存操作<memory.h>:
void memcpy(void d,void *s,int c);將s指向的內(nèi)存區(qū)域的c個(gè)字節(jié)復(fù)制到d指向的區(qū)域
類型轉(zhuǎn)換<stdlib.h>:
int atoi(char s);將字符串轉(zhuǎn)化為整數(shù)
char itoa(int v,char *s,int x);將整數(shù)v按x進(jìn)制轉(zhuǎn)成字符串s
時(shí)間<time.h>:
time_t time(time_t *timer);返回1970/1/1零點(diǎn)到目前的秒數(shù)
其他<stdlib.h>:
srand(unsigned seed);設(shè)置隨機(jī)數(shù)的種子
int rand();產(chǎn)生0-RAND_MAX的隨機(jī)數(shù)
exit(int);終止正在執(zhí)行的程序
轉(zhuǎn)載于:https://www.cnblogs.com/MarkKobs-blog/p/10456759.html
總結(jié)
以上是生活随笔為你收集整理的C++常用的系统函数的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: git撤销commit 并保存之前的修改
- 下一篇: 利用递归求某数的阶乘——C/C++