标签:b2b style printf lse end img str isp display
A Uva10815
#include<set> #include<string> #include<sstream>//stringstream #include<iostream> using namespace std; set<string> se; int main() { string x,y; while(cin>>x){ for (int i = 0; i < x.length(); ++i) if(isalpha(x[i])) x[i]=tolower(x[i]);//isalpha(x[i]) 判断是否为字母,tolower(x[i) 改编为小写字母 else x[i]=‘ ‘; stringstream ss(x);//文件流 while(ss>>y) se.insert(y); } for (set<string>::iterator j = se.begin(); j !=se.end() ; ++j) { cout<<*j<<‘\n‘; } return 0; }
C HDU -1412
1 #include<iostream> 2 #include<set> 3 using namespace std; 4 set<int >se; 5 int main() 6 { 7 8 int n,m; 9 while(scanf("%d%d",&n,&m)!=EOF) 10 { 11 int x; 12 for(int i=0;i<n;i++){ 13 scanf("%d",&x); 14 se.insert(x); 15 } 16 for(int i=0;i<m;i++){ 17 scanf("%d",&x); 18 se.insert(x); 19 } 20 set<int>::iterator it; 21 int flag=1; 22 for(it=se.begin();it!=se.end();it++) 23 { 24 if(flag) 25 cout<<*it,flag=0;//注意格式最后一个输出后无空格; 26 else cout<<‘ ‘<<*it; 27 } 28 cout<<endl; 29 se.clear(); 30 } 31 return 0; 32 }
E-HDU1004
1 #include<string> 2 #include<iostream> 3 #include<map> 4 #include<string> 5 using namespace std; 6 map<string,int>ma; 7 string s,ans; 8 int main() 9 { 10 int n; 11 while(scanf("%d",&n)!=EOF&&n) 12 { 13 string s; 14 for(int i=0;i<n;i++){ 15 cin>>s; 16 ma[s]++; 17 } 18 int num=0; 19 20 for(map<string,int>::iterator it=ma.begin();it!=ma.end();it++) 21 { 22 s=it->first; 23 if(ma[s]>num) { 24 ans=s; 25 num=ma[s]; 26 } 27 } 28 cout<<ans<<endl; 29 ma.clear(); 30 } 31 32 33 return 0; 34 }
HDU 1251
1 #include<stdio.h> 2 #include<string.h> 3 #include<map> 4 #include<string> 5 using namespace std; 6 map<string,int>ma; 7 int main() 8 { 9 char s[10]; 10 while(gets(s)) 11 { 12 int x=strlen(s); 13 if(x==0) 14 break; 15 for(int i=x-1;i>=0;i--) 16 { 17 ma[s]++;s[i]=‘\0‘; 18 } 19 } 20 while(scanf("%s",s)!=EOF) 21 { 22 printf("%d\n",ma[s]); 23 } 24 25 return 0; 26 }
标签:b2b style printf lse end img str isp display
原文地址:https://www.cnblogs.com/-xiangyang/p/9343692.html