求助,不懂啊哪错了
查看原帖
求助,不懂啊哪错了
866969
telankesi楼主2023/3/12 21:11
#include <stdio.h>;
#include <iostream>
#include <math.h>
#include<cstdio>
#include<algorithm>
using namespace ::std;
int n;
string s[1000010],m;
bool fun(string t) {
	string x;
	
	for (int i = 0; i < m.length(); i++) {
		x += t[i];
	}
	if (x == m)return true;
	else return false;
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf(" %s", &s[i]);
	}
	scanf(" %s", &m);
	sort(s + 1, s + 1 + n);
	for (int i = 1; i <= n; i++) {
		if (fun(s[i])) {
			cout << s[i] << endl;
		}
	}
	return 0;
}
2023/3/12 21:11
加载中...