cpp11/loops.cc
2012-05-05 14:05:47 -06:00

41 lines
655 B
C++

#include <string>
#include <vector>
#include <map>
#include <iostream>
using namespace std;
const vector<string> mcquays = {
"stephen",
"michael",
"bryan",
"derek",
};
int main() {
for(auto name: mcquays) {
cout << name << endl;
}
vector<int> nums = { 1, 2, 3, 4, 5 };
for(auto & n: nums) {
n--;
}
for(auto n: nums) {
cout << n << endl;
}
map<string, int> age_for_mcquay = {
{"stephen", 31},
{"michael", 29},
{"bryan", 27},
{"derek", 21},
};
for(auto p: age_for_mcquay) {
cout << p.first << " " << p.second << endl;
}
}