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

  17.     for(auto p: mp)   
  18.         cout<<p.first<<": "<<p.second<<endl;

  19.     cout<<"-------"<<endl;

  20.     for(auto it=mp.begin(); it!=mp.end(); it++)
  21.         cout<<(*it).first<<": "<<(*it).second<<endl;

  22.     return 0;
  23. }
複製代碼

TOP

返回列表