stl_map,set 用法
2014-01-21 23:50
169 查看
set:
集合a,b加起来,去重
hdu 1406
map的用法
hdu 4802
集合a,b加起来,去重
hdu 1406
#include <iostream> #include<cstdio> #include<set> using namespace std; int main(int argc, char** argv) { set<int> s; set<int>:: iterator cp; int a,b,n; while(scanf("%d%d",&a,&b)!=EOF){ s.clear(); int Max=0; for(int i=0;i<a+b;i++){ scanf("%d",&n); Max=(n>Max)?n:Max; s.insert(n); } for(cp=s.begin();cp!=s.end();cp++){ if(*cp!=Max) printf("%d ",*cp); else printf("%d\n",*cp); } } return 0; }
map的用法
hdu 4802
#include <iostream> #include<cstdio> #include<cstring> #include<map> using namespace std; int main(int argc, char** argv) { int n,all,a; double gpa; char str[10]; int i,j; map<string,double> mp; mp["A"]=4; mp["A-"]=3.7; mp["B+"]=3.3; mp["B"]=3; mp["B-"]=2.7; mp["C+"]=2.3; mp["C"]=2; mp["C-"]=1.7; mp["D"]=1.3; mp["D-"]=1; mp["F"]=0; while(scanf("%d",&n)!=EOF){ gpa=0; all=0; while(n--){ scanf("%d%s",&a,str); if(mp.find(str)!=mp.end()) all+=a,gpa+=mp[str]*a; } if(gpa!=0) gpa/=all; printf("%.2lf\n",gpa); } return 0; }
相关文章推荐
- STL基本用法【vector】【map】【string】【set】
- STL中的常用的vector,map,set,Sort用法
- STL中的常用的vector,map,set,Sort用法
- STL几个(set map vector string)用法
- stl几个(set map vector string)用法
- STL中的常用的vector,map,set,Sort用法
- STL中常用的vector,map,set 用法
- STL中的常用的vector,map,set,sort, list用法笔记 .
- STL中的常用的vector,map,set,Sort用法
- STL中的常用的vector,map,set,Sort用法
- STL中常用的vector,map,set 用法
- STL中常用的vector,map,set,sort 用法
- STL中的常用的vector,map,set,Sort用法
- STL中常用的vector,map,set,sort 用法
- STL 关联式容器 Set与Map的用法
- STL学习:STL库vector、string、set、map用法
- STL中的常用的vector,map,set,Sort用法
- STL中map,set的基本用法示例
- STL中的常用的vector,map,set,Sort用法 ——20110419
- STL中的常用的vector,map,set,Sort用法