1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| #include<iostream> #include<algorithm> #include<string> #include<vector> #include<list> #include<queue> #include<stack> #include<deque> #include<set> #include<map> using namespace std;
int main() { string str("abcde"); reverse(str.begin(), str.end()); cout << "string elem : "; for (int i = 0; i < str.size(); i++) cout << str.at(i) << " "; cout << "\n\n";
vector<int> v{ 1,2,3,4,5,6 }; reverse(v.begin(), v.end()); cout << "vector elem : "; for (vector<int>::iterator it = v.begin(); it != v.end(); it++) cout << *it << " "; cout << "\n\n"; list<int> l{ -1,-2,-3,-4,-5,-6 }; reverse(l.begin(), l.end()); cout << "list elem : "; for(list<int>::iterator it=l.begin();it!=l.end();it++) cout << *it << " "; cout << "\n"; l.reverse(); cout << "list elem : "; for (list<int>::iterator it = l.begin(); it != l.end(); it++) cout << *it << " "; cout << "\n\n";
queue<int> myq; myq.emplace(1); myq.push(2); stack<int> mys; mys.emplace(6); mys.push(7);
deque<int> myd{ 2,4,6,8 }; reverse(myd.begin(), myd.end()); cout << "deque elem : "; for (deque<int>::iterator it = myd.begin(); it != myd.end(); it++) cout << *it << " "; cout << "\n\n";
set<int> s; s.insert(10); s.insert(9); s.insert(8); cout << "set elem : "; for (set<int>::iterator it = s.begin(); it != s.end(); it++) cout << *it << " "; cout << "\n\n";
map<int, string> m; m.insert(make_pair(0, "小王")); m.insert(make_pair(1, "小玲")); cout << "map elem : " << "\n"; for (map<int, string>::iterator it = m.begin(); it != m.end(); it++) cout << "key : " << it->first << " value : " << it->second << endl; cout << "\n\n";
system("pause"); return 0; }
|