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

来源:互联网 发布:windows whistler安装 编辑:程序博客网 时间:2024/05/16 19:15
#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];elsesorted_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++]);elseprintf("%c", sorted_consonant[count_2++]);}printf("\n");}return 0;}

0 0