您的位置:首页 > 其它

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

2014-07-26 14:23 411 查看
#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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: