[백준/C++] 5704 - 팬그램

orangesnail·2025년 8월 11일

백준

목록 보기
136/169

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


전체 코드

알파벳 내의 각 문자가 등장했는지 등장하지 않았는지 저장하는 배열을 만든 뒤, 아스키코드를 이용해서 주어진 문자열의 각 문자에 대해 검사해야 한다.

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

int main() {
    while (true) {
        string sentence;
        getline(cin, sentence);

        if (sentence == "*") break;

        bool abc[26] = {false};
        for (char c : sentence) {
            if ('a' <= c && c <= 'z') 
                abc[c - 'a'] = true;
        }

        bool pangram = true;
        for (int i = 0; i < 26; i++) {
            if (!abc[i]) {
                pangram = false;
                break;
            }
        }
        if (pangram) cout << "Y" << endl;
        else cout << "N" << endl;
    }

    return 0;
}
profile
초보입니다. 피드백 환영합니다 😗

0개의 댓글