#include<iostream> #include<cstdio> using namespace std; void judge(int i, string s); int main() { string s; int m; while(cin >> s) { if(s == "END") break; cin >> m; for(int i = 1; i <= m; i++) { judge(i, s); } } return 0; } void judge(int i, string s) { string str; cin >> str; cout << i << ' '; if(str == s) { cout << "OK!" << endl; return; } if(s.length() == str.length()) { int pos; for(int i = 0; i < s.length(); i++) if(s[i] != str[i]) { pos = i; break; } cout << pos+1 << " change " << s[pos] << endl; } else if(s.length() > str.length()) { int pos; for(int i = 0; i < s.length(); i++) if(s[i] != str[i]) { pos = i; break; } cout << pos+1 << " insert " << s[pos] << endl; } else { int pos; for(int i = 0; i < str.length(); i++) if(s[i] != str[i]) { pos = i; break; } while(pos != 0 && str[pos] == str[pos-1]) pos--; cout << pos+1 << " delete " << str[pos] << endl; } return; } |
Double click to view unformatted code.