#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;
}
map索引的三种方式
最新推荐文章于 2023-04-11 16:02:23 发布