C++
棕熊的肚皮
无奋斗,不青春
展开
-
利用c++11 chrono库记录时间
在C++11中,是标准模板库中与时间有关的头文件。该头文件中所有函数与类模板均定义在std::chrono命名空间中。当我们想要记录模块代码或者函数的运算耗时的时候,可以利用chrono库实。相关的代码如下: #include <chrono> #include <iostream> class Timer { public: Timer(); virtual ~Timer(); int elapsedSecond(); int elapsedMil原创 2020-07-02 10:38:57 · 412 阅读 · 1 评论 -
C++中的stringstream的使用例子
本文主要记录stringstream的简单使用例子。 计算string中单词的个数 int countWords (string str){ stringstream s(str); string word; int count = 0; while (s>>word) count++; return count; } ...原创 2018-05-20 14:29:56 · 1224 阅读 · 0 评论