WA#5,求助
查看原帖
WA#5,求助
1259877
TipherethB楼主2024/8/6 15:55
#include <bits/stdc++.h>
using namespace std;

string s, t;

int main() {
	cin >> s >> t;
	int ls = s.length(), lt = t.length();
	if (ls > lt) {
		for (int i = 0; i <= ls - lt; i++) {
			for (int j = 0; j < lt; j++) {
				if (s[j] != t[j]) {
					break;
				}
			}
			cout << t << ' ' << "is substring of" << ' ' << s;
			return 0;
		}
		cout << "No substring";
		return 0;
	} else if (ls < lt) {
		for (int i = 0; i <= lt - ls; i++) {
			for (int j = 0; j < ls; j++) {
				if (s[j] != t[j]) {
					break;
				}
			}
			cout << s << ' ' << "is substring of" << ' ' << t;
			return 0;
		}
		cout << "No substring";
		return 0;
	} else if (ls == lt) {
		for (int j = 0; j < ls; j++) {
			if (s[j] != t[j]) {
				break;
			}
			cout << s << ' ' << "is substring of" << ' ' << t;
			return 0;
		}
		cout << "No substring";
		return 0;
	}
}
2024/8/6 15:55
加载中...