Last active
September 25, 2018 22:23
-
-
Save abranhe/fb2cd096754921c35dd6fa80654cf9a3 to your computer and use it in GitHub Desktop.
Collections using vectors.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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