Algorithm/BAEKJOON

[ C / C++ ] 백준 16360 Go Latin

곽수진 2022. 5. 17. 10:12
반응형

문제

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--;
	}
}
반응형