怎么向map<char,set<int> >插入数据?
#include<iostream>#include<map>#include<set>#include<iterator>#include<string>usingna...
#include<iostream>#include<map>#include<set>#include<iterator>#include<string>using namespace std;int main(){typedef map<char,set<int> > MyMap;typedef map<char,set<int> >::iterator MyMapIter;MyMap My_map;MyMapIter MyMap_iter; string TempItem("ABD");
string::iterator str;if(My_map.empty()){for(str=TempItem.begin();str!=TempItem.end();str++)
{
My_map['*str'].insert(1);
}
}for(MyMap_iter=My_map.begin();MyMap_iter!=My_map.end();MyMap_iter++){cout<<(*MyMap_iter).first<<" "<<(*MyMap_iter).second;//这地方是想输出map里的数据情况。</p><p>return 0;</p><p>} 展开
string::iterator str;if(My_map.empty()){for(str=TempItem.begin();str!=TempItem.end();str++)
{
My_map['*str'].insert(1);
}
}for(MyMap_iter=My_map.begin();MyMap_iter!=My_map.end();MyMap_iter++){cout<<(*MyMap_iter).first<<" "<<(*MyMap_iter).second;//这地方是想输出map里的数据情况。</p><p>return 0;</p><p>} 展开
1个回答
2013-04-01
展开全部
#include<iostream>
#include<map>
#include<set>
#include<iterator>
#include<string>
using namespace std;
int main()
{
typedef map<char,set<int> > MyMap;
typedef map<char,set<int> >::iterator MyMapIter;
MyMap My_map;
MyMapIter MyMap_iter;
string TempItem("ABD");
string::iterator str;
if(My_map.empty())
{
set<int> saaa;
saaa.insert(1);
for ( int i = 0; i < TempItem.length(); i++ )
{
My_map.insert( make_pair( TempItem.at(i),saaa) );
}
}
for(MyMap_iter=My_map.begin();MyMap_iter!=My_map.end();MyMap_iter++)
{
cout<<(*MyMap_iter).first<<" "<<*((*MyMap_iter).second.begin())<<endl;//这地方是想输出map里的数据情况。
}
return 0;
}
#include<map>
#include<set>
#include<iterator>
#include<string>
using namespace std;
int main()
{
typedef map<char,set<int> > MyMap;
typedef map<char,set<int> >::iterator MyMapIter;
MyMap My_map;
MyMapIter MyMap_iter;
string TempItem("ABD");
string::iterator str;
if(My_map.empty())
{
set<int> saaa;
saaa.insert(1);
for ( int i = 0; i < TempItem.length(); i++ )
{
My_map.insert( make_pair( TempItem.at(i),saaa) );
}
}
for(MyMap_iter=My_map.begin();MyMap_iter!=My_map.end();MyMap_iter++)
{
cout<<(*MyMap_iter).first<<" "<<*((*MyMap_iter).second.begin())<<endl;//这地方是想输出map里的数据情况。
}
return 0;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询