0分求调(楼主 is waste)
查看原帖
0分求调(楼主 is waste)
1390387
vector_STL_楼主2025/1/21 22:19
#include <bits/stdc++.h>
using namespace std;
#define int long long
string similar(string a, string b) {
	int x = a.size();
	int y = b.size();
	if (x == y+1) {
		a += '*';
		int cnt = 0;
		for (int i = 0; i < y; i++) {
			int c = 0;
			for (int j = 0; j < y; j++) {
				if (a[i] == b[j]) {
					c++;
				}

			}
			if (c >= 1) {
				cnt++;
			}
		}
		if (cnt >= y - 1) {
			return "similar";
		} else {
			return "not similar";
		}
	} else if (y == x-1) {
		b += '*';
		int cnt = 0;
		for (int i = 0; i < x; i++) {
			int c = 0;
			for (int j = 0; j < x; j++) {
				if (a[j] == b[i]) {
					c++;
				}

			}
			if (c >= 1) {
				cnt++;
			}
		}
		if (cnt >= x - 1) {
			return "similar";
		} else {
			return "not similar";
		}
	} else {
		int cnt = 0;
		for (int i = 0; i < y; i++) {
			int c = 0;
			for (int j = 0; j < y; j++) {
				if (a[j] == b[i]) {
					c++;
				}

			}
			if (c >= 1) {
				cnt++;
			}
		}
		if (cnt >= y - 1) {
			return "similar";
		} else {
			return "not similar";
		}
	}
	return "not similar";
}
signed main() {
	int n;
	cin >> n;
	string s[n + 5];
	int cne = 0;
	while (n--) {
		string a, b;
		cin >> a >> b;
		s[cne] = similar(a, b);
		cne++;
	}
	for (int i = 0; i < cne; i++) {
		cout << s[i] << endl;
	}
	return 0;
}
2025/1/21 22:19
加载中...