关于函数accumulate

这个累和的函数一定要注意两点:

1.这个函数在std里面和opencv里面都有,所以再用的时候,一定需要加上namespace,std::

int product = std::accumulate(v.begin(), v.end(), 0);

2.最后一个值0或者0.0决定了返回的数据类型,注意

同时这个函数还有将字符串连起来的功能

string sum = std::accumulate(v.begin(), v.end(), string(“”));

还有一些类似功能的函数:

equal,fill,fill_n等等,自行百度

猜你喜欢

转载自blog.csdn.net/qq_31638535/article/details/82699379
今日推荐