zrq495
www.zrq495.com

挺简单的,直接上代码。

 1 #include<stdio.h>
 2 #include<string.h>
 3 
 4 char str[100][100];
 5 
 6 int comp(int x, int y)
 7 {
 8     int n, m, i;
 9     n=strlen(str[x]);
10     m=strlen(str[y]);
11     if (n>m)
12         n=m;
13     for (i=0; i<n; i++)
14     {
15         if (str[x][i] != str[y][i])
16         return 1;
17     }
18     return 0;
19 }
20 
21 int main()
22 {
23     int k, flag, i, cas=1;
24     k=0;
25     flag=0;
26     while(gets(str[k]))
27     {
28         if (str[k][0] == '9')
29         {
30             if (flag == 0)
31                 printf("Set %d is immediately decodable\n", cas++);
32             else
33                 printf("Set %d is not immediately decodable\n", cas++);
34             k=0;
35             flag=0;
36             continue;
37         }
38         for (i=0; i<k; i++)
39         {
40             if (comp(k, i)==0)
41                 flag=1;
42         }
43         k++;
44     }
45     return 0;
46 }
posted on 2012-06-02 23:08  zrq495  阅读(171)  评论(0编辑  收藏  举报