C/C++常用头文件介绍

摘录→C++头文件大全

https://blog.csdn.net/sinolzeng/article/details/44920285

C语言常用头文件

1:#include <float.h>     //浮点数处理

float.h提供了浮点型的范围和精度的宏,没有类型和函数的定义,一般用于数值分析。

2:#include <fstream.h>         //文件输入/输出
一般用c++里的#include< iostream>
百度网址:https://baike.baidu.com/item/float.h/8210146?fr=aladdin

3:#include<limits.h> //定义各种数据类型最值常量
limits.h专门用于检测整型数据数据类型的表达值范围。

#include<stdio.h>
#include<limits.h>

main()
{
    printf("%d,%d\n", INT_MAX, INT_MIN);

    getchar();
}

4:#include <math.h>     //定义数学函数

常用sqrt函数,pow函数,fabs,abs函数等

5:#include<stdlib.h> //定义杂项函数及内存分配函数

stdlib.h头文件包括的常用的函数有malloc()、calloc()、realloc()、free()、system()、atoi()、atol()、rand()、srand()、exit()等等。

6:#include<string.h>    //字符串处理

参考博客详细讲解:https://www.cnblogs.com/haore147/p/3647555.html

7:#include<time.h>

参考博客详细讲解:https://www.cnblogs.com/haore147/p/3647579.html

c++常用头文件

1:#include <algorithm>    //STL通用算法

参考博客详细讲解:https://blog.csdn.net/ruibin_cao/article/details/83004968

2:#include <cmath>        //与c中<math.h>类似

3:#include <map>          

参考博客详细讲解:https://blog.csdn.net/wardseptember/article/details/80571363

4:#include <istream>     //基本输入流

参考博客详细讲解:https://blog.csdn.net/seadplus/article/details/7802346

5:#include <ostream>     //基本输出流

6:#include <queue>      //STL队列容器

如在SPFA算法最短路中需用到队列

参考博客详细讲解:https://www.cnblogs.com/xuning/p/3321733.html

扩展:priority_queue 优先队列

参考博客详解:https://www.cnblogs.com/Deribs4/p/5657746.html

7:#include <set>      //STL 集合容器

常用函数操作

begin()    ,返回set容器的第一个元素
end()   ,返回set容器的最后一个元素
clear()    删除set容器中的所有的元素
empty()    判断set容器是否为空
max_size()   ,返回set容器可能包含的元素最大个数
size()     ,返回当前set容器中的元素个数
rbegin    ,返回的值和end()相同
rend()     ,返回的值和rbegin()相同

8:#include <stack>      //STL堆栈容器

stack 的基本操作有:


入栈,如例:s.push(x);
出栈,如例:s.pop();注意,出栈操作只是删除栈顶元素,并不返回该元素。
访问栈顶,如例:s.top()
判断栈空,如例:s.empty(),当栈空时,返回true。
访问栈中的元素个数,如例:s.size()。

最后必须加上这个:   using namespace std;

猜你喜欢

转载自blog.csdn.net/weixin_43916296/article/details/86584528