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

#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;
}

你可能感兴趣的:(UVA 644 (暑假-字符串(2)-E - Immediate Decodability))