首页 > 编程语言 > 详细

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

时间:2015-05-07 22:13:15      阅读:239      评论:0      收藏:0      [点我收藏+]
#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

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!