1. cmath: 数学计算12345678910111213141516171819202122#include iostream#include cmathusingnamespacestd;intmain (){// 数字定义shorts 10;inti -1000;longl 100000;floatf 230.47;doubled 200.374;// 数学运算cout sin(d) :sin(d) endl;cout abs(i) :abs(i) endl;cout floor(d) :floor(d) endl;cout sqrt(f) :sqrt(f) endl;cout pow( d, 2) :pow(d, 2) endl;return0;}下面是一个关于生成随机数的简单实例。实例中使用了cime的time()函数来获取系统时间的秒数通过调用cstdlib的rand() 函数来生成随机数1234567891011#include iostream#include ctime#include cstdlibusingnamespacestd;srand( (unsigned)time( NULL ) );for(inti 0; i 10; i ){// 生成实际的随机数intjrand();cout 随机数 j endl;}如果使用相同的种子后面的rand()函数会出现一样的随机数。如srand(1)可以在宏定义中顶一个randomint number函数#define random(x)(rand()%x)2. iomanip格式化输出12345678910#includeiostream#includeiomanipusingnamespacestd;intmain(){doublex3.1415926;coutfixedsetprecision(3)xendl;return0;}3. nlohmann jsonjson解析nlohmann/json 是一个用于解析json的开源c库口碑一流号称有业界最好的性能并且使用非常方便直观是很多c程序员的首选。下载 https://github.com/nlohmann/json/tree/develop/single_include/nlohmann/json.hpp 并加入本地工程。使用方式如下4. opencv图像处理这里直接用了openvino里面带的opencv。将其拷贝到3rdparty文件夹下然后在CMakeLists中添加如下四行下面是使用例子5. openblas矩阵计算mac自带了openblas在/usr/local/Cellar下。将其拷贝到项目文件夹下在cmakelists里添加即可。关于api的文档参照这里https://blog.csdn.net/weixin_43800762/article/details/87811697首先是关键字接下来是到此这篇关于C中的常用库的文章就介绍到这了,
C++中的常用库
1. cmath: 数学计算12345678910111213141516171819202122#include iostream#include cmathusingnamespacestd;intmain (){// 数字定义shorts 10;inti -1000;longl 100000;floatf 230.47;doubled 200.374;// 数学运算cout sin(d) :sin(d) endl;cout abs(i) :abs(i) endl;cout floor(d) :floor(d) endl;cout sqrt(f) :sqrt(f) endl;cout pow( d, 2) :pow(d, 2) endl;return0;}下面是一个关于生成随机数的简单实例。实例中使用了cime的time()函数来获取系统时间的秒数通过调用cstdlib的rand() 函数来生成随机数1234567891011#include iostream#include ctime#include cstdlibusingnamespacestd;srand( (unsigned)time( NULL ) );for(inti 0; i 10; i ){// 生成实际的随机数intjrand();cout 随机数 j endl;}如果使用相同的种子后面的rand()函数会出现一样的随机数。如srand(1)可以在宏定义中顶一个randomint number函数#define random(x)(rand()%x)2. iomanip格式化输出12345678910#includeiostream#includeiomanipusingnamespacestd;intmain(){doublex3.1415926;coutfixedsetprecision(3)xendl;return0;}3. nlohmann jsonjson解析nlohmann/json 是一个用于解析json的开源c库口碑一流号称有业界最好的性能并且使用非常方便直观是很多c程序员的首选。下载 https://github.com/nlohmann/json/tree/develop/single_include/nlohmann/json.hpp 并加入本地工程。使用方式如下4. opencv图像处理这里直接用了openvino里面带的opencv。将其拷贝到3rdparty文件夹下然后在CMakeLists中添加如下四行下面是使用例子5. openblas矩阵计算mac自带了openblas在/usr/local/Cellar下。将其拷贝到项目文件夹下在cmakelists里添加即可。关于api的文档参照这里https://blog.csdn.net/weixin_43800762/article/details/87811697首先是关键字接下来是到此这篇关于C中的常用库的文章就介绍到这了,