stl头文件
include"vector" 容器头文件
#include "algorithm" 算法头文件
#include<vector> #include "algorithm"
vector<int > v1; v1.push_back(1); v1.push_back(2); v1.push_back(3); v1.push_back(4); v1.push_back(5); v1.push_back(6); v1.push_back(7); v1.push_back(7); v1.push_back(7); v1.push_back(7); for (vector<int>::iterator it = v1.begin(); it != v1.end(); it++) { cout << *it << endl; } int num=count(v1.begin(), v1.end(), 7); cout << "统计数据是:" << num << endl;