运行 ❯
获取您
自己的
网站
×
更改方向
更改主题,深色/浅色
转到 Spaces
#include <iostream> #include <map> using namespace std; int main() { // Create a map that will store the name and age of different people map<string, int> people = { {"John", 32}, {"Adele", 45}, {"Bo", 29} }; // Get the value associated with the key "John" cout << "John is: " << people["John"] << "\n"; // Get the value associated with the key "Adele" cout << "Adele is: " << people["Adele"] << "\n"; return 0; }
约翰是: 32
阿黛尔是: 45