안녕하세요. 오늘은 줄임말을 만들 거예요.

문제

https://www.acmicpc.net/problem/3181

아이디어

이 두 조건이 만족되면 출력하면 안됩니다.
1. 첫번째 단어가 아니고
2. 지문에 있는 열 단어중 하나라면

소스코드

#include <iostream>
using namespace std;

bool check(string s)
{
	string words[10] = { "i", "pa", "te", "ni", "niti", "a", "ali", "nego", "no", "ili"};
	for (string temp : words)
		if (s == temp)
			return true;
	return false;
}
char change(char c)
{
	return c - 'a' + 'A';
}

int main(void)
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	string s;

	int cnt = 0;
	while (cin >> s)
	{
		cnt++;

		if (cnt >= 2 && check(s)) continue;
		cout << change(s[0]);
	}
}


감사합니다.

0개의 댓글