您的位置:首页 > 其它

for 对vector类型进行循环输出

2017-04-19 00:07 295 查看
#include <iostream>
using namespace std;
int main(void)
{    vector<string> svec;
svec.push_back("I");
svec.push_back("LOVE");
svec.push_back("C++");
for (vector<string>::size_type ind = 0;ind != svec.size(); ++ind) {
cout << svec[ind]; // print current element
// if not the last element, print a space to separate from the next one
if (ind + 1 != svec.size())
cout << " ";
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: