求助~~例子都过了,什么情况下会出错啊~
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i,j,c,a1,b1;
string a,b;
cin>>n;
for(i=0;i<=n;i++){
cin>>a>>b;
if(a.size()<b.size()) swap(a,b);
a1=a.size();
b1=b.size();
c=0;
if(a1==b1){
for(j=0;j<a1;j++){
if(a[j]!=b[j]) c++;
}
}else if(a1-b1>1) c=2;
else{
for(j=0;j<b1;j++){
if(a[j]!=b[j]) {
a.erase(j,1);
if(a==b) c=0;
else c=2;
break;
}
}
}
if(c<=1) cout<<"similar"<<endl;
else cout<<"not similar"<<endl;
}
return 0;
}