vector
vector表示对象的集合,其中所有的对象类型相同。
vector是一个类模板:
vector<int> ivec;
向vector对象中添加元素
这里已经假定导入了头文件vector
string word;
vector<string> text;
while(cin >> word){
text.push_back(word);
}
vector例子
vector<unsigned> scores(11,0); //11个分数段,全部初始化为0
unsigned grade;
while(cin >> grade){
if(grade<=100)
++scores[grade/10];
}