المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : iterator



C++ Programming
07-02-2009, 12:20 AM
I've got this piece of code:

#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;
int main()
{
{

int ia11[30] = {3,9,17,21,24,31,33,36,42,49,
4,8,19,22,28,30,34,39,43,47,
2,6,10,13,14,25,29,37,38,46};
int ia34[30] ={1,6,12,15,22,27,31,32,41,42
,4,7,14,17,23,30,33,36,45,48
,2,9,13,18,21,26,34,39,44,49};
int ia72[30] = {3,8,11,18,22,25,36,37,43,46
,1,6,16,17,23,28,35,40,41,44
,2,5,12,19,24,27,31,34,42,49};
int ia167[30] ={3,4,12,15,21,28,32,39,47,48
,6,9,16,17,29,30,31,38,41,42
,7,8,11,20,26,27,34,35,45,46};
int ia190[30] = {3,10,11,14,22,23,32,35,43,44
,6,9,16,19,24,29,37,38,45,48
,2,5,13,18,25,30,31,40,41,0};
int ia21[30] ={ 2,5,16,19,25,30,34,39,45,48,
1,9,12,13,21,24,33,36,44,49,
3,8,15,20,23,26,35,40,43,46};
int ia64[30] ={6,9,13,20,28,29,33,40,43,48
,2,7,16,19,24,27,31,34,44,47
,5,8,14,17,21,30,32,37,41,46};
int ia102[30] ={4,9,14,19,22,29,35,38,46,47
,5,8,13,16,21,26,33,40,41,48
,6,7,15,17,28,30,32,39,42,45};
int ia178[30] ={6,9,15,20,23,24,37,38,42,45
,7,8,16,19,22,25,34,39,43,46
,1,2,17,18,26,29,31,40,47,0};
int ia180[30] ={1,4,13,18,27,30,33,38,45,46
,2,3,12,15,22,23,39,40,44,47
,8,9,11,17,24,25,32,37,49,0};

vector<int>via11(ia11,ia11+30);
vector<int>via34(ia34,ia34+30);
vector<int>via72(ia72,ia72+30);
vector<int>via167(ia167,ia167+30);
vector<int>via190(ia190,ia190+30);
vector<int>via21(ia21,ia21+30);
vector<int>via64(ia64,ia64+30);
vector<int>via102(ia102,ia102+30);
vector<int>via178(ia178,ia178+30);
vector<int>via180(ia180,ia180+30);

typedef map<string,vector<int>>container;
container::iterator it;
container map;

map.insert(make_pair("ia11", via11));
map.insert(make_pair("ia34", via34));
map.insert(make_pair("ia72", via72));
map.insert(make_pair("ia167", via167));
map.insert(make_pair("ia190", via190));
map.insert(make_pair("ia21", via21));
map.insert(make_pair("ia64", via64));
map.insert(make_pair("ia102", via102));
map.insert(make_pair("ia178", via178));
map.insert(make_pair("ia180", via180));


for (it=map.begin();it!(=map.end();++it))
cout<<it->second<<; //the compiler stops here!
cout<<endl;
}
system("PAUSE");
return (0);
}
At the very end there is an error. I,d like the iterator /it/ to find vectors of integers intelligently and display them in the order the strings in the map container appear. I don't know how to do it. Could anybody possibly help me?