#include <cstdio> #include <string> #include <iostream> using namespace std; int main(){ string word; while(cin>>word){ if(word=="END") break; int n; cin>>n; int len=word.length(); for(int i=1;i<=n;i++){ string myword; cin>>myword; int mylen=myword.length(); if(mylen<len){//短了 int pos=1;//短在哪里 char ss=word[0]; int ll=mylen-1; for(int i=len-1;i>=0;i--){ if(ll>=0){ if(word[i]!=myword[ll]){ pos=i+1; ss=word[i]; break; } ll--; } } cout<<i<<" "<<pos<<" insert "<<ss<<endl; } else if(mylen==len){//错了 或者对了 int pos;//错在哪里 char ss; int flag=1;//默认对的 for(int i=0;i<len;i++){ if(word[i]!=myword[i]){ pos=i+1; ss=word[i]; flag=0; break; } } if(flag) cout<<i<<" "<<"OK!"<<endl; else cout<<i<<" "<<pos<<" change "<<ss<<endl; } else if(mylen>len){//长了 int pos=1;//长在哪里 char ss=myword[0]; int ll=len-1; for(int i=mylen-1;i>=0;i--){ if(ll>=0){ if(myword[i]!=word[ll]){ pos=i+1; ss=myword[i]; break; } ll--; } } cout<<i<<" "<<pos<<" delete "<<ss<<endl; } } } return 0; } |
Double click to view unformatted code.