| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
为什么是错的#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string str1,str2;
int aray1[26]={0},aray2[26]={0};
char a[26]={0},b[26]={0};
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
int len1,len2,i,j,k,l,c=0,d=0;
getline(cin,str1);
getline(cin,str2);
len1=str1.length();
len2=str2.length();
for ( i=0;i<len1-1;i++)
for(j=i+1;j<len1;j++)
if(str1[i]>str1[j])
{
int temp1=str1[i];
str1[i]=str1[j];
str1[j]=temp1;
}
for( k=0;k<len2-1;++k)
for(l=k+1;l<len2;++l)
if(str2[k]>str2[l])
{
int temp=str2[k];
str2[k]=str2[l];
str2[l]=temp;
}
for(i=0;i<len1;i++)aray1[str1[i]-'A']++;
for(k=0;k<len2;k++)aray2[str2[k]-'A']++;
for(j=0;j<26;j++)
if(aray1[j]!=0)
{
a[c]=aray1[j]+48;
c++;
}
a[c]='\0';
for(l=0;l<26;l++)
if(aray2[l]!=0)
{
b[d]=aray2[l]+48;
d++;
}
b[d]='\0';
//for(i=0;i<26;i++)cout<<a[i]<<" ";
//cout<<endl;
//for(i=0;i<26;i++)cout<<b[i]<<" ";
//cout<<endl;
int same;
same=strcmp(a,b);
if(same==0)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
//system("pause");
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator