~cpp // no644 - Immediate Decodability #include <iostream> #include <cstring> using namespace std; const int MAX = 10; int main() { char code[MAX][11]; int i, j, k; int count = 1; int nCode, len; bool isDecodable; while (cin.peek() != EOF) { for (i=0; i<MAX; i++) { cin.getline(code[i], 11, '\n'); if (code[i][0] == '9') break; } nCode = i; for (i=0; i<nCode; i++) { for (j=0; j<nCode; j++) { if (i==j) continue; isDecodable = false; len = strlen(code[i]); for (k=0; k<len; k++) { if (code[i][k] != code[j][k]) { isDecodable = true; break; } } if (isDecodable == false) break; } if (isDecodable == false) break; } cout << "Set " << count++; if (!isDecodable) cout << " is not immediately decodable\n"; else cout << " is immediately decodable\n"; } return 0; }