社区讨论
求掉,运行错误,支持互关T_T
B3958[GESP202403 四级] 相似字符串参与者 3已保存回复 3
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 3 条
- 当前快照
- 1 份
- 快照标识符
- @mid5otco
- 此快照首次捕获于
- 2025/11/24 21:01 3 个月前
- 此快照最后确认于
- 2025/11/24 21:23 3 个月前
CPP
# include <bits/stdc++.h>
using namespace std;
int main(){
int n,ans=0;
cin>>n;
string a,b,c;
for(int i=1;i<=n;i++){
cin>>a>>b;
if(a.size()==b.size()){
ans=0;
for(int j=0;j<a.size();j++){
if(a[j]!=b[j]) ans++;
}
if(ans>1) cout<<"not similar"<<'\n';
else cout<<"similar"<<'\n';
}
else if(abs(a.size()-b.size())<2){
if(a.size()>b.size()){
c=b;
b=a;
a=c;
}
int x=0,y=0,f=0;
ans=0;
while(x<a.size()){
if(a[x]!=b[y]){
ans++;
if(ans>2){ f=1;break;}
y++;
}
else{
x++;
y++;
}
}
if(f==1) cout<<"not similar"<<'\n';
else cout<<"similar"<<'\n';
}
else cout<<"not similar"<<'\n';
}
return 0;
}
运行错误,希望大佬改改(感谢大佬,支持互关
回复
共 3 条回复,欢迎继续交流。
正在加载回复...