#include <iostream>
#include <map>
using namespace std;

int main(){
    map<int,int> m;
    for (int i = 0; i < 10; i++){
        m[i] = i*i;
    }
    map<int,int>::iterator iter;
    iter = m.begin();
    while(iter != m.end()){
        cout << iter->first << "-" << iter->second << endl;
        iter++;
    }
    for (iter = m.begin();iter != m.end(); iter++){
        cout << iter->first << "-" << iter->second << endl;
    }
    for(auto &it : m){
        cout << it.first << "-" << it.second <<endl;
    }
    return 0;
}

相关文章:

  • 2021-10-06
  • 2021-06-29
  • 2021-12-08
  • 2021-12-01
  • 2021-10-25
  • 2021-07-22
猜你喜欢
  • 2021-11-19
  • 2022-12-23
  • 2022-12-23
  • 2021-08-27
  • 2022-02-11
相关资源
相似解决方案