반응형
문제
There are English words that you want to translate them into pseudo-Latin. To change an English word into pseudo-Latin word, you simply change the end of the English word like the following table.
Englishpseudo-Latin
-a | -as |
-i, -y | -ios |
-l | -les |
-n, -ne | -anes |
-o | -os |
-r | -res |
-t | -tas |
-u | -us |
-v | -ves |
-w | -was |
If a word is not ended as it stated in the table, put ‘-us’ at the end of the word. For example, a word “cup” is translated into “cupus” and a word “water” is translated into “wateres”.
Write a program that translates English words into pseudo-Latin words.
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
int main(void) {
int num;
scanf("%d", &num);
while (num > 0) {
char str[31];
scanf("%s", str);
switch (str[strlen(str) - 1]) {
case 'a':
printf("%ss\n", str);
break;
case 'i':
printf("%sos\n", str);
break;
case 'y':
str[strlen(str) - 1] = '\0';
printf("%sios\n", str);
break;
case 'l':
printf("%ses\n", str);
break;
case 'n':
str[strlen(str) - 1] = '\0';
printf("%sanes\n", str);
break;
case 'e':
if (str[strlen(str) - 2] == 'n') {
str[strlen(str) - 1] = '\0';
str[strlen(str) - 1] = '\0';
printf("%sanes\n", str);
}
else
printf("%sus\n", str);
break;
case 'o':
printf("%ss\n", str);
break;
case 'r':
printf("%ses\n", str);
break;
case 't':
printf("%sas\n", str);
break;
case 'u':
printf("%ss\n", str);
break;
case 'v':
printf("%ses\n", str);
break;
case 'w':
printf("%sas\n", str);
break;
default:
printf("%sus\n", str);
break;
}
num--;
}
}
반응형
'Algorithm > BAEKJOON' 카테고리의 다른 글
[ C / C++ ] 백준 17363 우유가 넘어지면? (0) | 2022.05.19 |
---|---|
[ C / C++ ] 백준 16504 종이접기 (0) | 2022.05.18 |
[ C / C++ ] 백준 15815 천재 수학자 성필 (0) | 2022.05.16 |
[ C / C++ ] 백준 15664 N과 M(10) (0) | 2022.05.15 |
[ C / C++ ] 백준 15663 N과 M(9) (0) | 2022.05.14 |