/* * UVA_10252.cpp * * Created on: 2013年10月28日 * Author: Administrator */ #include#include #include #include using namespace std; const int maxn = 1010; int main(){ // char str1[maxn],str2[maxn]; string str1,str2; while(getline(cin,str1),getline(cin,str2)){//所有输入都是字符串并且每2行为一组测试用例,可以尝试这样输入,用shile(scanf("%s%s",str1,str2))会TLE int len1 = str1.length(); int len2 = str2.length(); int a[26];//用来存储字母表 int b[26]; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); int i; for(i = 0 ; i < len1 ; ++i){//统计str1中每个字符出现的次数 a[str1[i] - 'a']++; } for(i = 0 ; i < len2 ; ++i){ b[str2[i] - 'a']++; } for(i = 0 ; i < 26 ; ++i){ int time = min(a[i],b[i]); while(time--){ // printf("%c",i+'a'); 采用这种输出方式会WA,我算彻底服了....我真心看不出哪里有不同 cout<