accumulate() demo

来源:互联网 发布:服装店最新版收银软件 编辑:程序博客网 时间:2024/05/22 05:08
#include <iostream>#include <vector>#include <algorithm>#include <string>using namespace std;int main(){    vector<string> svec = { "hello", "world", "hello", "sun" };    auto result = accumulate(svec.begin(), svec.end(), string(""));    cout << result << endl;    vector<int> ivec = { 1, 2, 3, 4 };    auto result2 = accumulate(ivec.begin(), ivec.end(), 0);    cout << result2 << endl;    return 0;}

0 0
原创粉丝点击