本帖最后由 szt1993 于 2024-3-26 13:30 编辑
c++标准库: 1、标准库的特性: 2、C++编译环境的组成: 3、C++标准库预定义了很多常用的数据结构: -<bitset> -<set> -<cstdio>
-<deque> -<stack> -<cstring>
-<list> -<vector> -<cstdlib>
-<queue> -<map> -<cmath>
代码示例: - <font color="rgb(117, 113, 94)">#include <cstdio></font>
- <font color="rgb(117, 113, 94)">#include <cstring></font>
- <font color="rgb(117, 113, 94)">#include <cstdlib></font>
- <font color="rgb(117, 113, 94)">#include <cmath></font>
- using namespace std;//所谓命名空间,是一种将程序库名称封装起来的方法,它就像在各个程序库中立起一道道围墙
- int main()
- {
- <font color="rgb(166, 226, 46)">printf</font>(<font color="rgb(166, 226, 46)">"Hello world!\n"</font>);
- char* p = (char*)malloc(16);
- strcpy(p, <font color="rgb(166, 226, 46)">"TXP"</font>);
- double a = 3;
- double b = 4;
- double c = sqrt(a * a + b * b);
- <font color="rgb(166, 226, 46)">printf</font>(<font color="rgb(166, 226, 46)">"c = %f\n"</font>, c);
- free(p);
- <font color="rgb(166, 226, 46)">return</font> 0;
- }
输出结果: - root@txp-virtual-machine:/home/txp<font color="rgb(117, 113, 94)"># ./a.out</font>
- Hello world!
- c = 5.000000
|