C标准函数库

整型函数stdlib.h

  1. 算术
int abs(int value);
long int labs(long int value);
div_t div(int numerator, int denominator);
div_t ldiv( long intt numer, long int denom); 

abs函数返回绝对值,div函数把第二个参数除以第一个参数,产生余数和商
div_t结构为

int quot;
int rem;

2.随机数

int rand(void);
void srand(unsigned int seed);

void srand( (unsigned int)time(0));

rand函数返回范围0到RAND_MAX之间的伪随机数
srand用它的参数值对随机数发生器进行初始化
3.字符串转换

int atoi(char const *string); 
//转化为整型
long int atol(char const *string);
//转化为长整型
long int strtol( char const *string, char **unused, int base); 
//转化为long  
unsigned long int strtoul( char const *string, char **unused, int base); 

字符中前导的空白字符将会被跳过,然后把合法的字符进行转化,任何非法的缀尾字符进会被忽略掉。
strtol保存一个指向转换值后面第一个字符,若第二个参数并非NULL,这个指针便保存在第二个参数所指向的位置,此指针允许字符串的剩余部分进行处理;第三个参数是转换所执行的基数,若为0,程序中任何用于书写整数字面值形式将会被接受。

浮点型函数 math.h

1.三角函数

double sin(double angle);
double cos(double angle);
double tan(double angle);
double asin(double angle);
double acos(double angle);
double atan(double angle);
double atan2(double x, double y);  // y/x的反正切

//双曲函数
double sinh(double angle);
double cosh(double angle);
double tanh(double angle);

//对数指数
double exp( double x);
double log( double x);//ln  以e为底的对数
double log10( double x);

//浮点表示形式  存储一个浮点值
double frexp(double value, int *exponent) ;
double ldexp(double fraction, int exponent) ;
double modf(double value, double *ipart) ;//将浮点值分为整数和小数

//幂
double pow(double x, double y);//x的y次方
double sqrt( double x);//返回x的平方根

//底数、顶数、绝对值、余数
double floor( double x);//返回不大于其参数的最大整数值
double ceil( double x);//返回不小于其参数的最小整数值
double fabs( double x);//返回其参数的绝对值
double fmod( double x, double y);//x/y所产生的余数

//字符串转化
double atof( char const *string);
double strtod( char const *string, char **unused);

时期与时间函数 time.h

1.clock 函数返回从程序开始执行起处理器所消耗的时间。

clock_t clock(void );

2.当天的时间

time_t time( time_t *returned_value );

若指针非空,时间值将通过指针进行存储。

char *ctime( time_t const *time_value);
double difftime(time_t time1, time_t time2);

ctime函数返回一个指向字符串的指针
difftime函数计算time1-time2的差,并转化为秒

非本地跳转 setjmp.h

int setjmp( jmp_buf state);
void longjmp( jump_buf state, int value);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值