#include<stdio.h> #include<iostream> #include<string.h> using namespace std; int main() { char str[2222],ss[2222]; int a; while(scanf("%s",str)) { if(strcmp(str,"END")==0) { break; } scanf("%d",&a); for(int i=1;i<=a;i++) { scanf("%s",ss); if(strlen(str)==strlen(ss)) { int j; for(j=0;j<strlen(str);j++) { if(ss[j]!=str[j]) { cout<<i<<' '<<j+1<<" change "<<str[j]<<endl; break; } } if(j==strlen(str)) cout<<i<<" OK!"<<endl; } else if(strlen(str)>strlen(ss)) { int p; for(int j=0;j<strlen(str);j++) { if(ss[j]!=str[j]) { p=j; break; } } while(p!=0&&str[p]==str[p-1]) { p--; } cout<<i<<' '<<p+1<<" insert "<<str[p]<<endl; } else { int p; for(int j=0;j<strlen(ss);j++) { if(ss[j]!=str[j]||j==strlen(ss)-1) { p=j; break; } } while(p!=0&&ss[p]==ss[p-1]) { p--; } cout<<i<<' '<<p+1<<" delete "<<ss[p]<<endl; } } } return 0; } |
Double click to view unformatted code.