Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Example of vector using pushback
- #include<vector>
- #include<iostream>
- using namespace std;
- int main(){
- vector<int>v(5);
- for(int i=0;i<10;i++){
- //v[i]=i+1;
- v.push_back(i+1);
- }
- for(int i=0;i<10;i++){
- cout<<v[i]<<" ";
- }
- cout<<endl;
- cout<<"There are "<<v.size()<<" elements in your vector"<<endl;
- return 0;
- }
Add Comment
Please, Sign In to add comment