这道题交了4遍才AC,也不懂是什么原因
#include <cstdio>
#include <string.h>
using namespace std;
const int maxn=20;
char a[maxn][maxn],tmp[maxn];
int tot=-1,count=0;
int main()
{
#ifndef ONLINE_JUDGE
freopen("644.in","r",stdin);
freopen("644.out","w",stdout);
#endif
while (scanf("%s",a[++tot])==1)
{
if (a[tot][0]!='9')continue;
bool is=true;
--tot;
for (int i=0; i<=tot&&is; i++)
for (int j=0; j<=tot&&is; j++)
if (i!=j&&strlen(a[j])>=strlen(a[i]))
{
sprintf(tmp,"%.*s",strlen(a[i]),a[j]);
if (strcmp(tmp,a[i])==0)
is=false;
}
printf("Set %d is ",++count);
if (is)
printf("immediately decodable\n");
else printf("not immediately decodable\n");
tot=-1;
}
fclose(stdin);
fclose(stdout);
return 0;
}