반응형
https://www.acmicpc.net/problem/12517
12517번: Centauri Prime (Small1)
Back in the old days before the creation of the mighty Centauri Republic, the planet Centauri Prime was split into several independent kingdoms. The kingdom of Mollaristan was ruled by king Loatold, while the kingdom of Auritania was under the rule of quee
www.acmicpc.net
단순 string 문제였습니다.
* a 유무 조심
📕 Code
#include <bits/stdc++.h>
using namespace std;
char s[30];
int testCase, cnt;
int main(){
cin >> testCase;
while(cin >> s){
cnt++;
char lastChar, k[10];
lastChar = s[strlen(s)-1];
if(lastChar == 'y') strcpy(k,"nobody");
else if(
lastChar == 'a' ||
lastChar == 'e' ||
lastChar == 'i' ||
lastChar == 'o' ||
lastChar == 'u'
) strcpy(k,"a queen");
else strcpy(k,"a king");
printf("Case #%d: %s is ruled by %s.\n", cnt, s, k);
}
}
'Algorithm > String' 카테고리의 다른 글
(C++) - 백준(BOJ) 15927번 : 회문은 회문아니야!! (2) | 2021.08.13 |
---|---|
(C++) - 백준(BOJ) 12518번 : Centauri Prime (Small2) (0) | 2021.08.04 |
(C++) - 백준(BOJ) 8545번 : Zadanie próbne (0) | 2021.08.03 |
(C++) - 백준(BOJ) 11117번 : Letter Cookies (0) | 2021.08.03 |
(C++) - 백준(BOJ) 4889번 : 안정적인 문자열 (2) | 2021.08.01 |