IOS开发之----常用函数和常数(本文只为记录,可去原文查看详细)

来源:互联网 发布:哪个软件听歌好 编辑:程序博客网 时间:2024/05/17 08:46
原文地址:    http://blog.sina.com.cn/s/blog_71715bf80101bnvn.html  


bfs广度优先搜索

算术函数

【算术函数】函数名说明int rand()随机数生成。
(例)
srand(time(nil)); //随机数初期化
int val = rand()P; //0~49之间的随机数int abs(int a)整数的绝对值
(例)int val = abs(-8);
 →8
※浮点数的时候用fabs。double fabs(double a)浮点数的绝对值
(例)double val = fabs(-12.345);
 →12.345
※整数的时候用abs。double floor(double a)返回浮点数整数部分(舍弃小数点)
(例)double val = floor(12.345);
 →12.000double ceil(double a);返回浮点数整数部分(舍弃小数点部分,往个位数进1)
(例)double val = ceil(12.345);
 →13.000double pow(double a, double b)a的b次方
(例)double val = pow(2, 3);
 →8double sqrt(double a)a的平方根
(例)double val = sqrt(2);
 →1.41421356

三角函数

【三角函数】函数名说明double cos(double a)余弦函数 (a:弧度)double sin(double a)正弦函数 (a:弧度)double tan(double a)正切函数 (a:弧度)double asin(double a)反正弦值 (a:弧度)double acos(double a)反余弦函数(a:弧度)double atan(double a)反正切函数double atan2(double a, double b)返回给定的 a 及 b 坐标值的反正切值

指数函数

【指数函数】函数名说明double log(double a)以e 为底的对数值double log10(double a)对数函数log

常数

常数常数名说明M_PI圆周率(=π)M_PI_2圆周率的1/2(=π/2)M_PI_4圆周率的1/4(=π/4)M_1_PI=1/πM_2_PI=2/πM_E=eM_LOG2Elog_2(e)M_LOG10Elog_10(e)





0 0
原创粉丝点击