/C06017 - Tập từ riêng của hai xâu 1

<Problem>

https://code.ptit.edu.vn/student/question/C06017
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <ctype.h>


void split(char s[], char arr[100][100], int* n) {
	int len = 0;

	const char* delim = " ";
	char* token = strtok(s, delim);

	while (token != NULL) {
		strcpy(arr[len++], token);

		token = strtok(NULL, delim);
	}

	*n = len;
}

int main() {
	char s1[100];
	char s2[100];

	gets(s1);
	gets(s2);

	char arr1[100][100];
	char arr2[100][100];
	char res[100][100];
	int n1, n2, n3 = 0;

	split(s1, arr1, &n1);
	split(s2, arr2, &n2);


	for (int i = 0; i < n1; i++) {
		bool check = true;

		for (int j = 0; j < n2; j++) {
			if (strcmp(arr1[i], arr2[j]) == 0) {
				check = false;
				break;
			}
		}

		if (check) {
			strcpy(res[n3++], arr1[i]);
		}
	}

	for (int i = 0; i < n3 - 1; i++) {
		for (int j = n3 - 1; j > i; j--) {
			if (strcmp(res[j], res[j - 1]) < 0) {
				char tmp[100];
				strcpy(tmp, res[j]);
				strcpy(res[j], res[j - 1]);
				strcpy(res[j - 1], tmp);
			}
		}
	}

	for (int i = 0; i <= n3 - 2; i++) {
		if (strcmp(res[i], res[i + 1]) == 0) continue;
		printf("%s ", res[i]);
	}

	printf("%s ", res[n3 - 1]);

	return 0;
}