题目就是统计数组a,b所有字符出现的次数,然后看c数组中字符是不是和他们相同。
这道题用string真的是太太方便了,上代码:
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
string s,s2,s3;
using namespace std;
int main( )
{
while(cin>>s>>s2>>s3)
{
string s1=s+s2;
sort(s1.begin(),s1.end());
sort(s3.begin(),s3.end());
if(s1==s3)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}
注意如果这里用char字符数组来解决的话,一定要用strstr()函数,虽然没有string这么方便,但是同样很好用啊
#include<bits/stdc++.h>
#define maxn 300
using namespace std;
char s[maxn],s2[maxn],s3[maxn],s4[maxn];
int main( )
{
while(~scanf("%s%s%s",&s,&s2,&s3)
{
strcat(s,s2);
int n=strlen(s);
int m=strlen(s3);
sort(s,s+n);
sort(s3,s3+m);
if(n!=m)
printf("NO\n");
else
{
if(strstr(s,s3))
printf("YES\n");
else
printf("NO\n");
}
}
return 0;
}