实际还是挺简单的,1Y.
#include <iostream>
#include<algorithm>#include <stdio.h>
#include <stdlib.h>
#include"string.h"
using namespace std;
char str[105];
char temp1[105];
char ch[105];
char temp2[105];
int len1,len2;
void rank(char s[],int len)
{
sort(s,s+len);
}
bool match(char s1[],char s2[])
{
int i=0,j=0;
for(j=0;j<len2&&i<len1;i++)
{
if(s1[i]==s2[j])
j++;
}
if(j==len2)
return 1;
else
return 0;
}
int main()
{
int i;
scanf("%s%s",str,ch);
len1=strlen(str),len2=strlen(ch);
strcpy(temp1,str);
strcpy(temp2,ch);
if(len1==len2)
{
sort(temp1,temp1+len1);
sort(temp2,temp2+len2);
for(i=0;i<len1;i++)
if(temp1[i]!=temp2[i])
{
printf("need tree\n");
break;
}
if(i==len1)
printf("array\n");
}
else
{
if(match(temp1,temp2))
printf("automaton\n");
else
{
sort(temp1,temp1+len1);
sort(temp2,temp2+len2);
if(match(temp1,temp2))
printf("both\n");
else
printf("need tree\n");
}
}
}