ZOJ-1858

#include<stdio.h>

int main()
{
    int map[26], i;
    map['B' - 'A'] = map['F' - 'A'] = map['P' - 'A'] = map['V' - 'A'] = 1;
    map['C' - 'A'] = map['G' - 'A'] = map['J' - 'A'] = map['K' - 'A'] = 2;
    map['Q' - 'A'] = map['S' - 'A'] = map['X' - 'A'] = map['Z' - 'A'] = 2;
    map['D' - 'A'] = map['T' - 'A'] = 3;
    map['L' - 'A'] = 4;
    map['M' - 'A'] = map['N' - 'A'] = 5;
    map['R' - 'A'] = 6;
    map['A' - 'A'] = map['E' - 'A'] = map['I' - 'A'] = map['O' - 'A'] = 0;
    map['U' - 'A'] = map['H' - 'A'] = map['W' - 'A'] = map['Y' - 'A'] = 0;

    char s[20];
    while (scanf("%s", s) != EOF)
    {
        int prev = 0;
        int curr;
        for (i = 0; s[i] != '\0'; i++)
        {
            curr = map[s[i] - 'A'];
            if (curr && prev != curr)
                printf("%d", curr);
            prev = curr;
        }
        putchar('\n');
    }
    return 0;
}

没有更多推荐了,返回首页