#include #include #include #include #include #include using namespace std; char matrix[10][7][6]; char localMatrix[7][30]; bool testNumber (int number, int startIndex ){ char ch; for (int r = 0; r < 7; ++r){ for (int c = 0; c < 5; ++c){ ch = localMatrix[r][c+startIndex]; if (ch == '.') continue; if (ch != matrix[number][r][c]) return false; } } return true; } int getNumber (int start){ int found = -1; int i; for (i = 0; i < 10; ++i){ if (testNumber(i, start)){ found = i; break; } } cout << found << endl; if (found == -1) return -1; for (; i < 10; ++i){ if (testNumber(i, start)){ return -1; } } return found; } bool processInput (){ int num; ostringstream os; if ((num = getNumber(0)) != -1) os << num; else return false; if ((num = getNumber(7)) != -1) os << num; else return false; os << ':'; if ((num = getNumber(17)) != -1) os << num; else return false; if ((num = getNumber(24)) != -1) os << num; else return false; cout << os.str() << '\n'; return true; } int main() { strcpy(matrix[0][0], "+---+"); strcpy(matrix[0][1], "| |"); strcpy(matrix[0][2], "| |"); strcpy(matrix[0][3], "+ +"); strcpy(matrix[0][4], "| |"); strcpy(matrix[0][5], "| |"); strcpy(matrix[0][6], "+---+"); strcpy(matrix[1][0], " +char localMatrix[7][30];"); strcpy(matrix[1][1], " |"); strcpy(matrix[1][2], " |"); strcpy(matrix[1][3], " +"); strcpy(matrix[1][4], " |"); strcpy(matrix[1][5], " |"); strcpy(matrix[1][6], " +"); strcpy(matrix[2][0], "+---+"); strcpy(matrix[2][1], " |"); strcpy(matrix[2][2], " |"); strcpy(matrix[2][3], "+---+"); strcpy(matrix[2][4], "| "); strcpy(matrix[2][5], "| "); strcpy(matrix[2][6], "+---+"); strcpy(matrix[3][0], "+---+"); strcpy(matrix[3][1], " |"); strcpy(matrix[3][2], " |"); strcpy(matrix[3][3], "+---+"); strcpy(matrix[3][4], " |"); strcpy(matrix[3][5], " |"); strcpy(matrix[3][6], "+---+"); strcpy(matrix[4][0], "+ +"); strcpy(matrix[4][1], "| |"); strcpy(matrix[4][2], "| |"); strcpy(matrix[4][3], "+---+"); strcpy(matrix[4][4], " |"); strcpy(matrix[4][5], " |"); strcpy(matrix[4][6], " +"); strcpy(matrix[5][0], "+---+"); strcpy(matrix[5][1], "| "); strcpy(matrix[5][2], "| "); strcpy(matrix[5][3], "+---+"); strcpy(matrix[5][4], " |"); strcpy(matrix[5][5], " |"); strcpy(matrix[5][6], "+---+"); strcpy(matrix[6][0], "+---+"); strcpy(matrix[6][1], "| "); strcpy(matrix[6][2], "| char localMatrix[7][30];"); strcpy(matrix[6][3], "+---+"); strcpy(matrix[6][4], "| |"); strcpy(matrix[6][5], "| |"); strcpy(matrix[6][6], "+---+"); strcpy(matrix[7][0], "+---+"); strcpy(matrix[7][1], " |"); strcpy(matrix[7][2], " |"); strcpy(matrix[7][3], " +"); strcpy(matrix[7][4], " |"); strcpy(matrix[7][5], " |"); strcpy(matrix[7][6], " +"); strcpy(matrix[8][0], "+---+"); strcpy(matrix[8][1], "| |"); strcpy(matrix[8][2], "| |"); strcpy(matrix[8][3], "+---+"); strcpy(matrix[8][4], "| |"); strcpy(matrix[8][5], "| |"); strcpy(matrix[8][6], "+---+"); strcpy(matrix[9][0], "+---+"); strcpy(matrix[9][1], "| |"); strcpy(matrix[9][2], "| |"); strcpy(matrix[9][3], "+---+"); strcpy(matrix[9][4], " |"); strcpy(matrix[9][5], " |"); strcpy(matrix[9][6], "+---+"); char localMatrix[7][30]; while (true){ if (!cin) break; cin.getline(localMatrix[0], 30); if (!strcmp(localMatrix[0], "end")) break; for (int i = 1; i < 7; ++i){ cin.getline (localMatrix[i], 30); } cin.get(); cin.get(); if (!processInput()) cout << "ambiguous\n"; } cout << "end" << flush; return 0; }