返回列表 發帖
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. map<int, string> mp;
  4. int main()
  5. {
  6.     mp[2]="t";
  7.     mp[7]="s";
  8.     mp[1]="o";
  9.     mp[5]="f";
  10.     mp[6]="s";
  11.     mp[9]="n";
  12.     mp[6]="s2";   
  13.    
  14.     for(int i=0; i<=10; i++)
  15.     {
  16.         cout<<i<<": "<<mp[i]<<endl;
  17.     }
  18.     for(auto p: mp)
  19.     {
  20.         cout<<p.first<<": "<<p.second<<endl;
  21.     }
  22.     cout<<"-------"<<endl;

  23.     for(auto it=mp.begin(); it!=mp.end(); it++)
  24.     {
  25.         cout<<(*it).first<<": "<<(*it).second<<endl;
  26.     }
  27.     return 0;
  28. }
複製代碼

TOP

返回列表