UVA 10152 (暑期-线性表-E- ShellSort)

#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace std;

int main() {
	int t;
	scanf("%d", &t);
	while (t--) {
		int n;
		scanf("%d", &n);
		getchar();
		char str_1[250][100], str_2[250][100];
		memset(str_2, 0, sizeof(str_2));

		for (int i = 0; i < n; i++) {
			gets(str_1[i]);
		}
		for (int i = 0; i < n; i++) {
			gets(str_2[i]);
		}
		

		int kong = n - 1;
		for (int i = n - 1; i >= 0; i--) {
			for (int j = kong; j >=0; j--) {
				if (strcmp(str_2[i], str_1[j]) == 0) {
					str_2[i][99] = 1;
					kong = j - 1;
					break;
				}
			}
			if (str_2[i][99] == 0)
				break;
		}
		for (int i = n - 1; i >= 0; i--)
			if (str_2[i][99] == 0)
				puts(str_2[i]);
		printf("\n");
	}

	return 0;
}

你可能感兴趣的:(UVA 10152 (暑期-线性表-E- ShellSort))