cpp11/loops.cc

41 lines
655 B
C++
Raw Normal View History

2012-05-05 12:45:44 -07:00
#include <string>
#include <vector>
2012-05-05 13:05:47 -07:00
#include <map>
2012-05-05 12:45:44 -07:00
#include <iostream>
using namespace std;
const vector<string> mcquays = {
"stephen",
"michael",
"bryan",
"derek",
};
int main() {
2012-05-05 13:05:47 -07:00
for(auto name: mcquays) {
cout << name << endl;
}
2012-05-05 12:45:44 -07:00
2012-05-05 13:05:47 -07:00
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;
}
2012-05-05 12:45:44 -07:00
}