/C06015 - Chuẩn hóa xâu họ tên 2

<Problem>

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


int main() {
	int t;
	scanf("%d", &t);

	getchar();

	while (t--) {
		char s[200];
		gets(s);

		char arr[100][100];
		int n = 0;

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

		while (token != NULL) {
			token[0] = toupper(token[0]);

			for (int i = 1; i < strlen(token); i++) {
				token[i] = tolower(token[i]);
			}

			strcpy(arr[n++], token);

			token = strtok(NULL, delim);
		}

		for (int i = 1; i < n; i++) {
			if (i < n - 1) printf("%s ", arr[i]);
			else printf("%s, ", arr[i]);
		}

		for (int i = 0; i < strlen(arr[0]); i++) {
			arr[0][i] = toupper(arr[0][i]);
		}

		printf("%s", arr[0]);

		printf("\n");

	}

	return 0;
}