C++常用的系统函数

本文详细介绍了C语言标准库中数学库(math.h)的各种函数,包括三角函数、反三角函数、双曲三角函数、指数与对数函数、取整函数、绝对值函数、标准化浮点数函数、取整与取余函数以及平方根函数。此外,还介绍了字符处理(ctype.h)、字符串(string.h)、内存操作(memory.h)、类型转换(stdlib.h)、时间(time.h)等库的常用函数。

数学<math.h>:

1 三角函数
double sin (double);
double cos (double);
double tan (double);
2 反三角函数
double asin (double); 结果介于[-PI/2, PI/2]
double acos (double); 结果介于[0, PI]
double atan (double); 反正切(主值), 结果介于[-PI/2, PI/2]
double atan2 (double, double); 反正切(整圆值), 结果介于[-PI/2, PI/2]
3 双曲三角函数
double sinh (double);
double cosh (double);
double tanh (double);
4 指数与对数
double exp (double x); e的x次幂
double pow (double x, double y); x的y次幂
double sqrt (double);
double log (double x); 以e为底的对数,即ln x
double log10 (double x);log10(x) 以10为底。

没有以2为底的函数但是可以用换底公式解 决:log2(N)=log10(N)/log10(2)
5 取整
double ceil (double); 不小于x的最小整数
double floor (double); 不大于x的最大整数
6 绝对值

int abs(int);整型
long labs(long);长整型
double fabs (double);浮点型

7 标准化浮点数
double frexp (double f, int p); 标准化浮点数, 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*); 将参数的整数部分通过指针回传, 返回小数部分
double fmod (double, double); 返回两参数相除的余数

9.平方根

double sqrt(double x);

字符<ctype.h>:

int isalpha(int c);c是否为字母
int isdigit(int c);c是否为数字
int tolower(int c);将c转换为小写字母
int toupper(int c);将c转换为大写字母

字符串<string.h>:

char strcpy(char sl,char s2);将字符串s2复制给s1,即覆盖
unsigned strlen(char
sr);求字符串str长度

内存操作<memory.h>:

void memcpy(void d,void *s,int c);将s指向的内存区域的c个字节复制到d指向的区域

类型转换<stdlib.h>:

int atoi(char s);将字符串转化为整数
char
itoa(int v,char *s,int x);将整数v按x进制转成字符串s

时间<time.h>:

time_t time(time_t *timer);返回1970/1/1零点到目前的秒数

其他<stdlib.h>:

srand(unsigned seed);设置随机数的种子
int rand();产生0-RAND_MAX的随机数
exit(int);终止正在执行的程序

转载于:https://www.cnblogs.com/MarkKobs-blog/p/10456759.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值