UVA 10785 (暑假-排序、检索(2)-E-The Mad Numerologist )

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int main() {
	char sound[] = {"AUEOI"};
	char consonant[] = {"JSBKTCLDMVNWFXGPYHQZR"};
	
	int t, k = 0;	
	scanf("%d", &t);
	while (k++ < t) {
		printf("Case %d: ", k);
		int n;
		scanf("%d", &n);
		int sorted_sound[250];
		int sorted_consonant[250];
		int j = 0, l = 0;

		for (int i = 0; i < n; i++) {
			if (i%2 == 0)	
				sorted_sound[j++] =  sound[i/42];
			else
				sorted_consonant[l++] = consonant[i/10];
		}
		sort(sorted_sound,sorted_sound + j);
		sort(sorted_consonant,sorted_consonant + l);

		int count_1 = 0;
		int count_2 = 0;
		for (int i = 0; i < n; i++) {
			if (i%2 == 0)	
				printf("%c", sorted_sound[count_1++]);
			else
				printf("%c", sorted_consonant[count_2++]);
		}

		printf("\n");
	}
	return 0;
}

你可能感兴趣的:(UVA 10785 (暑假-排序、检索(2)-E-The Mad Numerologist ))