【算法】简单的使用vector的输入输出(C++源码)

这里实现一个简单的vector的输入输出

#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>

using namespace std;

void put_vec(vector<int>&v)
{
for(size_t i=0 ; i<v.size() ; ++i)
{
cin>>v[i];
}
}

void print_vec(const vector<int>&v)
{
for(size_t i=0 ; i<v.size() ; ++i)
{
cout<<v[i]<<" ";
}
cout<<endl;
}

int main()
{
vector<int>vec_a;
int vec_size;
cout<<"Please put the number size:";
cin>>vec_size;
vec_a.resize(vec_size);
cout<<"Please put the numbers:";
put_vec(vec_a);
cout<<"Print the numbers:";
print_vec(vec_a);
return 0;
}