vector和map

来源:互联网 发布:js实现扑克牌自动洗牌 编辑:程序博客网 时间:2024/05/20 05:03
#include "stdafx.h"#include<iostream>#include<vector>#include<string>#include<map>using namespace std;int _tmain(int argc, _TCHAR* argv[]){typedef map<int,string>  word;vector<word>  vec;word wd1;word wd2;wd1.insert(make_pair(1, "hello"));wd1.insert(make_pair(2, "vector"));wd2.insert(make_pair(3, "hello"));wd2.insert(make_pair(4, "map"));vec.push_back(wd1);vec.push_back(wd2);for(vector<word>::iterator wordIter = vec.begin(); wordIter != vec.end(); ++wordIter){for(word::iterator iter = wordIter->begin(); iter != wordIter->end(); ++iter){cout << iter->first << " " << iter->second << endl;}}return 0;}

0 0
原创粉丝点击