练习12.7
2016-09-07 本文已影响0人
狂舞曲少WA几个好不
···
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;
}
···