码迷,mamicode.com
首页 > 编程语言 > 详细

C++ Primer第四版习题--5.18

时间:2015-05-07 22:14:45      阅读:168      评论:0      收藏:0      [点我收藏+]

标签:c++ primer第四版

#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main()
{
    vector<string*> spvec;
    string str;
    while(cin>>str)
    {
        string *sp = new string;
        *sp = str;
        spvec.push_back(sp);
    }

    vector<string*>::iterator iter = spvec.begin();
    while(iter!=spvec.end())
    {
        cout << **iter << "\t" << (**iter).size() << endl;
        ++iter;
    }

    iter = spvec.begin();
    while(iter!=spvec.end())
    {
        delete *iter;
        ++iter;
    }
    return 0;
}

C++ Primer第四版习题--5.18

标签:c++ primer第四版

原文地址:http://blog.csdn.net/xumesang/article/details/45565325

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!