팬그램 (백준 5704)

코딩생활·2023년 11월 13일
0

백준문제풀이

목록 보기
55/308

안녕하세요. 오늘은 팬그램을 확인해볼 거예요.

문제

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

아이디어

문자열을 getline으로 받아서 한번에 모든 줄을 입력받은 다음, 문자가 있는지 없는지 확인하고 하나라도 없으면 N을 출력해주면 됩니다.

소스코드

#include <iostream>
#include <string>
using namespace std;

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

    while (true)
    {
        getline(cin, s);
        if (s == "*") break;

        bool ck[26] = { 0 };
        for (char c : s)
            if (c != ' ')
                ck[c - 'a'] = true;

        bool able = true;
        for (int i = 0; i < 26; i++)
            if (ck[i] == 0)
                able = false;
        if (able) cout << "Y\n";
        else cout << "N\n";
    }
}


감사합니다.

0개의 댓글