Skip to content

Instantly share code, notes, and snippets.

@abranhe
Last active September 25, 2018 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abranhe/fb2cd096754921c35dd6fa80654cf9a3 to your computer and use it in GitHub Desktop.
Save abranhe/fb2cd096754921c35dd6fa80654cf9a3 to your computer and use it in GitHub Desktop.
Collections using vectors.
// Run it online
// https://repl.it/@abranhe/Pluralsight-1-4-vectors
//
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
vector<int> vi;
for(int i=0; i<10; i++)
{
vi.push_back(i);
}
for(auto item:vi)
{
cout << item << " ";
}
cout << endl;
vector<string> vs;
cout << "Enter three words ";
for(int i=0; i<3; i++)
{
string s;
cin >> s;
vs.push_back(s);
}
for(auto item:vs)
{
cout << item << " ";
}
cout << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment