| 42 | } |
| 43 | |
| 44 | int main() |
| 45 | { |
| 46 | int a[5] = {1, 2, 3, 4, 5}; |
| 47 | vector<int> nums(a, a + 5); |
| 48 | // C++11新方式 |
| 49 | for(auto num: nums) { |
| 50 | cout << num << ' '; |
| 51 | } |
| 52 | cout << endl; |
| 53 | cout << isPossible(nums); |
| 54 | cout << endl; |
| 55 | |
| 56 | unordered_map<char, int> mp; |
| 57 | for(int i = 0; i < 5; ++ i) { |
| 58 | mp['a' + i] = i; |
| 59 | } |
| 60 | for (auto i : mp) { |
| 61 | cout << i.first << "->" << i.second << ' '; |
| 62 | } |
| 63 | cout << endl; |
| 64 | |
| 65 | // unordered_map查找某个键或者同级某个键 |
| 66 | cout << "find('a') " << (*mp.find('a')).first << "->" << (*mp.find('a')).second << endl; |
| 67 | cout << "count('a') " << mp.count('a') << endl; |
| 68 | |
| 69 | |
| 70 | // 初始化unordered_map |
| 71 | unordered_map<int, int> mpa; |
| 72 | cout << "test: " << mpa[0] << endl; |
| 73 | return 0; |
| 74 | } |
| 75 |
nothing calls this directly
no test coverage detected