美文网首页
练习12.7

练习12.7

作者: 狂舞曲少WA几个好不 | 来源:发表于2016-09-07 21:57 被阅读0次

    ···

    include <iostream>

    include <vector>

    include <memory>

    using namespace std;

    shared_ptr<vector<int>> new_vector(void) {
    return make_shared<vector<int>>();
    }
    void read_ints(shared_ptr<vector<int>> spv) {
    int v;
    while (cin >> v) {
    spv->push_back(v);
    }
    }
    void print_ints(shared_ptr<vector<int>> spv) {
    for (const auto &v : *spv) {
    cout << v << " ";
    }
    cout << endl;
    }
    int main(int argc, char **argv)
    {
    auto spv = new_vector();
    read_ints(spv);
    print_ints(spv);
    return 0;
    }
    ···

    相关文章

      网友评论

          本文标题:练习12.7

          本文链接:https://www.haomeiwen.com/subject/qjfsettx.html