set,map用于统计输出
2015-05-08 18:46
155 查看
读入整数,数量不定,当输入0结束,求出现的数及其次数:
int main(){ int a; multiset<int>ss; cout<<"enter"<<endl; cin>>a; while(a!=0){ ss.insert(a); cin>>a;} cout<<"the inf:"<<endl; multiset<int>::iterator p; for(p=ss.begin();p!=ss.end();p++) cout<<*p<<" "; //int *p1=new int [ss.size()]; cout<<"\n max of number"<<max<int>(ss)<<endl; map<int,int>m1; for(p=ss.begin();p!=ss.end();p++) m1.insert(map<int,int>::value_type(*p,ss.count(*p))); cout<<"the inf of all:"<<endl; map<int,int>::iterator p1; for(p1=m1.begin();p1!=m1.end();p1++) cout<<p1->first<<" "<<p1->second<<endl; system("pause"); return 0;}
相关文章推荐
- 使用map&set统计单词个数
- setInc 和 setDec 用于统计字段,数据数字类型 更新操作
- velocity对set 类型的支持 map get输出问题分析
- velocity对set 类型的支持 map get输出问题分析
- Map实现从0~100中随机生成50个数,统计出现的数字最大值和最小值,输出出现最多的次数及对应的数字
- Context3D类中的setBlendFactors方法(指定用于使用现有颜色混合绘制操作的输出颜色的系数)
- 1058: [ZJOI2007]报表统计 set+map+priority_queue
- velocity对set 类型的支持 map get输出问题分析
- 结构体用于map,set时要重载运算符<
- java:Set,Map排序输出到Writer
- 自己写的javascript map 函数, 用于统计字符出现次数
- vector/list/set/map 遍历耗时统计
- iostat命令——用于输出CPU和磁盘I/O相关的统计信息
- C++STL--map和set 词频统计和单词转换
- java中 Set与Map排序输出到Writer详解及实例
- map与set的简单综合应用,统计单词词频
- MYSQL统计每天数据,用于做图表的输出统计数据
- Java中list、set、map的输出格式
- 结构体用于map,set时要重载运算符<
- iostat 用于输出 CPU 和磁盘 I/O 相关的统计信息。