- 1、本文档共7页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
C语言函数积累
使用前要注明:#includectype.h
isdigit():判断字符是否是数字(0–9)isalpha():判断字符是否是字母(A–Z or a–z)isxdigit():判断是否是十六进制字符(A–F, a–f, or 0–9)isalnum():判断是否是数字和字母(A–Z, a–z, or 0–9)isupper():判断字符是否为大写英文字母islower():判断字符是否为小写英文字母toupper():将字符转换为大写英文字母tolower():把字符转换成小写字母ispunct():判断字符是否为标点符号有两个函数可以实现,double pow(double x, double y),double pow10(int p)
下面是这两个函数的使用方法,个人建议用:pow10(n)
函数名: pow
功 能: 指数函数(x的y次方)
用 法: double pow(double x, double y);
程序例:
#include math.h
#include stdio.h
int main(void)
{
double x = 2.0, y = 3.0;
printf(%lf raised to %lf is %lf\n, x, y, pow(x, y));
return 0;
}
函数名: pow10
功 能: 指数函数(10的p次方)
用 法: double pow10(int p);
程序例:
#include math.h
#include stdio.h
int main(void)
{
double p = 3.0;
printf(Ten raised to %lf is %lf\n, p, pow10(p));
return 0;
}
三角函数:(所有参数必须为弧度)??1.acos
? 函数申明:acos? (double x);?? 用途:用来返回给定的 X 的反余弦函数。
?2.asin
?? 函数申明:asin? (double x);?? 用途:用来返回给定的 X 的反正弦函数。
?3.atan?
?? 函数申明:atan? (double x);?? 用途:用来返回给定的 X 的反正切函数。
?4.sin
?? 函数声明:sin?? (double x);?? 用途:用来返回给定的 X 的正弦值。
?5.cos
?? 函数声明:cos?? (double x);?? 用途:用来返回给定的 X 的余弦值。
?6.tan
?? 函数声明:tan?? (double x);?? 用途:用来返回给定的 X 的正切值。
?7.atan2
?? 函数声明:atan2 (double y, double x);?? 用途:返回给定的 X 及 Y 坐标值的反正切值?其他函数:
?8.atof?
? 函数名: atof? (const char *s);? 功? 能: 把字符串转换成浮点数? 用? 法: double atof(const char *nptr);? 程序例:?? #i nclude stdlib.h?? #i nclude stdio.h
?? int main(void)?? {
??? float arg,*point=arg;??? float f;??? char *str = 12345.67;
??? f = atof(str);??? printf(string = %s float = %f\n, str, f);??? return 0;?? }
?9.?ceil? 和 floor
?? 函数名: ceil? ?????????????? ? floor ?? 功? 能: 向上舍入??????? 向下舍入?? 用? 法: double ceil(double x);??????? double floor(double x);?? 程序例:
?? #i ncludemath.h
?? int main(void)?? {??? double number = 123.54;??? double down, up;
??? down = floor(number);??? up = ceil(number);
??? printf(original number???? %5.2lf\n, number);??? printf(number rounded down %5.2lf\n, down);??? printf(number rounded up?? %5.2lf\n, up);
???
您可能关注的文档
最近下载
- 请求对虚假诉讼审查的申请书(参考范本).docx
- 2025年吉林省高考语文作文猜题及范文.pdf
- 空调用铝合金衬耐热聚乙烯复合管道工程技术规程,T_CECS533-2018.pdf
- 凯迪拉克XT5说明书.pptx
- 第三单元 维持生命的物质——氧气、水实验教学设计---2024-2025学年九年级化学科粤版(2024)上册.docx
- 初识读后续写(一、二).pptx
- 网络营销实务(第三版)课件 1.1任务一 初识网络营销.pptx
- 幼儿园绘本《爱书的孩子》 优质课件.ppt
- 电气施工强制性条文执行记录表汇总表.docx VIP
- 广东省广州市越秀区2023-2024学年八年级下学期期末语文试题(含答案).pdf VIP
文档评论(0)