#include<stdio.h>
#include<string.h>
int isSameReflection(char*word1,char *word2)
{
int c1=0,c2=0,i,j;
for(j=0;word1[j]!=0;j++)
{
for(i=0;i<strlen(word1);i++)
if(word1[i]==word1[0])
c1++;
for(i=0;i<strlen(word2);i++)
if(word2[i]==word1[0])
c2++;
if(c1==c2)
{
j++;
continue;
}
else
return -1;
}
return 1;
}
int main() {
char s1[100],s2[100];
// fgets(s1,100,stdin);
//fgets(s2,100,stdin);
scanf("%s",s1);
scanf("%s",s2);
printf("%d",isSameReflection(s1,s2));
}
input
abc cab
output
1
#include<string.h>
int isSameReflection(char*word1,char *word2)
{
int c1=0,c2=0,i,j;
for(j=0;word1[j]!=0;j++)
{
for(i=0;i<strlen(word1);i++)
if(word1[i]==word1[0])
c1++;
for(i=0;i<strlen(word2);i++)
if(word2[i]==word1[0])
c2++;
if(c1==c2)
{
j++;
continue;
}
else
return -1;
}
return 1;
}
int main() {
char s1[100],s2[100];
// fgets(s1,100,stdin);
//fgets(s2,100,stdin);
scanf("%s",s1);
scanf("%s",s2);
printf("%d",isSameReflection(s1,s2));
}
input
abc cab
output
1
No comments:
Post a Comment