Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ctype.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- static char t(char);
- static char t(char c) {
- static const char *tab[] = { "aehiouwy", "bfpv", "cgjkqsxz", "dt", "l", "mn", "r" };
- if (!islower(c)) {
- return c;
- }
- for (size_t i = 0; i < sizeof tab / sizeof tab[0]; ++i) {
- if (strchr(tab[i], c)) {
- return '0' + i;
- }
- }
- // NOTREACHED
- return '\0';
- }
- int main(void) {
- char buf[BUFSIZ];
- if(!fgets(buf, BUFSIZ, stdin)) {
- goto end;
- }
- int len = strlen(buf);
- if (buf[len - 1] == '\n') {
- buf[len - 1] = '\0';
- --len;
- }
- if (len < 1) {
- goto end;
- }
- for (int i = 0; i < len; ++i) {
- if (!isalpha(buf[i])) {
- goto end;
- }
- }
- char *p = buf;
- char *prev = NULL;
- do {
- if (strchr("aeiouy", *p)) {
- prev = p;
- continue;
- }
- if (strchr("hw", *p)) {
- continue;
- }
- if (!prev || t(*prev) != t(*p)) {
- printf("%c", t(*p));
- }
- prev = p;
- } while (*++p);
- puts("");
- exit(0);
- end:
- exit(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement