样例过了,但0!!!!!!!分!!!!!!!!
查看原帖
样例过了,但0!!!!!!!分!!!!!!!!
1285326
wzjDD楼主2024/8/24 14:29

样例过了,但0!!!!!!!分!!!!!!!! 求指教

#include<bits/stdc++.h>
using namespace std;
char a[100000],b[100000];
int main(){
	int n,c = 0;
	cin>>n;
	for(int i = 1;i <= n;i++){
		c = 0;
		cin>>a>>b;
		if(strlen(a) > strlen(b)){
			if(strlen(a) - strlen(b) > 1){
				cout<<"not similar";
				continue;
			}
			if(strlen(a) - strlen(b) < 2)
				c++;
			for(int j = 0;j < strlen(b);j++){
				if(a[j] != b[j]){
					for(int l = 0,ll = 0;l < strlen(b) && ll < strlen(b);l++,ll++){
						if(a[l] == a[j])
							l++;
						if(a[l] != b[ll]){
							c++;
						}
					}
				}
			}
		}
		if(strlen(b) > strlen(a)){
			if(strlen(b) - strlen(a) > 1){
				cout<<"not similar"<<endl;
				continue;
			}
			if(strlen(b) - strlen(a) < 2)
				c++;
			for(int j = 0;j < strlen(a);j++){
				if(a[j] != b[j]){
					for(int l = 0,ll = 0;l < strlen(a) && ll < strlen(a);l++,ll++){
						if(b[l] == b[j])
							l++;
						if(b[l] != a[ll]){
							c++;
						}
					}
				}
					
			}
		}
		if(c > 1)
			cout<<"not similar"<<endl;
		else
			cout<<"similar"<<endl;
	}
	return 0; 
	
}

2024/8/24 14:29
加载中...