各种函数头文件集合

1、sqrt
(1)头文件 #include <cmath>
(2)作用:取根号
2、strlen
(1)头文件#include <cstring>
(2)作用:计数字符串的长度
2、strcpy
(1)头文件 #include <cstring>
(2)作用:拷贝
3、string
(1)头文件 #include <cstring>
(2)作用:定义字符串函数
4、max
(1)头文件#include <algorithm>
(2)作用:比较出两者中的最大值
5、min
(1)头文件#include <algorithm>
(2)作用:比较出两者中的最小值
6、万能头文件
(1)头文件#include <bits/stdc++.h>
7、get
(1)头文件#include <stdio.h>
8、printf
(1)头文件#include <stdio.h>
9、sort
(1)头文件#include <algorithm>
(2)作用:默认从小到大排序
10、memcpy
(1)头文件 #include <cstring>
(2)作用:可以拷贝任何类型的对象,因为函数的参数类型是void*(未定义类型指针),也就是说传进去的实参可以是int*,short*,char*等等。
(3)形式:memcpy(void *dest, void *src, unsigned int count);
例如:memcpy(d,s,strlen(s));

memcpy(scores,score,n*sizeof(int));//注意最后一项;

由src所指内存区域复制count个字节到dest所指内存区域
11、find
(1)头文件#include <algorithm>
(2)find算法从一个容器中查找制定的区间,常用迭代器位置描述该区间,如果在[begin,end]区间找到与a相等的值,则返回区间中等于a的第一个元素,如果没有找到就返回最后元素的位置。
12、abs
(1)头文件#include <cstdlib>
13、fabs
(1)头文件#include <cmath>
14、multiset
(1)头文件#include <set>
15、typeid
(1)头文件#include <typeinfo>;
(2)作用
在多态程序中,利用typeid获取基类指针所指的实际对象,并进行不同的成员函数调用

typeid是C++的一个关键字,等同于sizeof这类操作符。typeid操作符的返回结果是名为type_info的标准库类型的对象的引用。type_info的name成员函数返回C-style的字符串。

typeid操作符在程序运行时判定一个对象的真实数据类型
16、__gcd(n,m)
(1)头文件#include <algorithm>
(2)作用:求两个数的最大公约数;

猜你喜欢

转载自blog.csdn.net/fighting123678/article/details/79657702