赞
踩
下面是关于字符串中count的两种用法,STL容器,数组的用法类似
#include <iostream> #include <string> #include <algorithm> //count using namespace std; int main() { string m = "1233445"; //int n = count(m.data(), m.data()+m.size(),'3'); int n = count(m.begin(), m.end(),'3'); cout << n << endl; return 0; } //vector用法: cout << count(v.begin(), v.end(), 6) << endl; //数组用法: cout << count(a, a + 10, 4) << endl;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。