样例绿,提交红
查看原帖
样例绿,提交红
1341958
an_qu_Lei_nuo_yi_er楼主2024/8/28 17:50
#include <iostream>
#include <string>
using namespace std;

bool similar(string a,string b){
	int t = 0;
	if(a.size() - b.size() >= 1) t = t + (a.size() - b.size());
	for(int i = 0;i < a.size();i++){
		if(i < b.size() and a[i] != b[i]) t++;
	}
	if(t > 1) return false;
	return true;
}

int main(){
	int n;
	string a,b;
	cin>>n;
	for(int i = 0;i < n;i++){
		cin>>a>>b;
		if(a.size() < b.size()){
			string t = a;
			a = b;
			b = t;
		}
		if(similar(a,b)) cout<<"similar\n";
		else cout<<"not similer"<<endl;
	}
	return 0;
}
2024/8/28 17:50
加载中...