| ||||||||||
| 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 | |||||||||
why??两个有区别吗????#include <stdio.h>
#include <string.h>
int main ()
{
char s1[110];
char s2[110];
int l1,l2;
int c1[26],c2[26];
int i,j;
memset (c1,0,sizeof(c1));
memset (c2,0,sizeof(c2));
scanf ("%s",s1);
scanf ("%s",s2);
l1=strlen (s1); l2=strlen (s2);
if (l1!=l2) { printf ("NO\n"); return 1; }
for (i=0;i<l1;i++) c1[s1[i]-'A']++;
for (i=0;i<l2;i++) c2[s2[i]-'A']++;
for (i=0;i<26;i++)
{
for (j=0;j<26;j++)
if (c1[i]==c2[j]) break;
if (j>=26) break;
c2[j]=0;
}
if (i<26) printf ("NO\n");
else printf ("YES\n");
return 1;
}
AC~~~~~~~~~~~~!!!!!!!!!!!!!!!!
****************************************************************
这个wa~~~~~~~~~~~~~~~????
#include <stdio.h>
#include <string.h>
int main()
{
char s1[101],s2[101];
int l1,l2;
int i,j;
int c1[26],c2[26];
memset(c1,0,sizeof(c1));
memset(c2,0,sizeof(c2));
scanf("%s",s1);
scanf("%s",s2);
l1=strlen(s1);
l2=strlen(s2);
if(l1!=l2) { printf("NO\n");return 0;}
for(i=0;i<l1;i++) c1[s1[i]-'A']++;
for(i=0;i<l2;i++) c1[s2[i]-'A']++;
for(i=0;i<26;i++)
{
for(j=0;j<26;j++)
if(c1[i]==c2[j]) break;
if(j>=26) break;
c2[j]=0;
}
if(i<26) printf("NO\n");
else printf("YES\n");
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator