UVA 644 (暑假-字符串(2)-E - Immediate Decodability)

来源:互联网 发布:ipython for windows 编辑:程序博客网 时间:2024/06/07 08:22
#include <cstdio>#include <cstring>#include <cstdlib>int main() {char str[100][100];int num = 0;for (int i = 0; gets(str[i]); i++) {if (str[i][0] == '9') {int kong = 0;for (int j = 0; j < i; j++) {if (kong)break;for (int k = 0; k < i; k++) {if (j == k)continue;int count = 0;while (str[j][count] == str[k][count++]);if (count == strlen(str[j]) + 1) {printf("Set %d is not immediately decodable\n", ++num);kong = 1;break;}}}if (!kong)printf("Set %d is immediately decodable\n", ++num);i = -1;memset(str, 0, sizeof(str));}}return 0;}

0 0