#include<iostream> #include<iomanip> #include<string> using namespace std; int main() { string r; while (cin >> r) { if (r == "END") { return 0; } int m; char c; string temp; string temp2; cin >> m; int flag = 0; for (int i = 1; i <= m; ++i) { cin >> temp; if (temp == r) { cout << i << " OK!" << endl; } else if (temp.size() == r.size()) { int j; for (j = 0; j < temp.size(); ++j) { if (temp[j] != r[j]) { cout << i << " " << j + 1 << " change " << r[j] << endl; break; } } } else if (temp.size() < r.size()) { for (int i = 0; i < temp.size(); ++i) { c = r[i]; temp2 = temp; if (temp2.insert(i, 1, c) == r) { cout << i << " " << i + 1 << " insert " << r[i] << endl; break; } } } else if (temp.size() > r.size()) { for (int i = 0; i < temp.size(); ++i) { c = temp[i]; temp2 = temp; if (temp2.erase(i, 1) == r) { cout << i << " " << i + 1 << " delete " << temp[i] << endl; break; } } } } } } |
Double click to view unformatted code.