题目描述:
A word or a sentence in some language is called a pangram if all the characters of the alphabet of this language appear in it at least once. Pangrams are often used to demonstrate fonts in printing or test the output devices.
You are given a string consisting of lowercase and uppercase Latin letters. Check whether this string is a pangram. We say that the string contains a letter of the Latin alphabet if this letter occurs in the string in uppercase or lowercase.
输入描述:
The first line contains a single integer n (1 ≤ n ≤ 100) — the number of characters in the string.
The second line contains the string. The string consists only of uppercase and lowercase Latin letters.
输出描述:
Output “YES”, if the string is a pangram and “NO” otherwise.
输入:
12
toosmallword
35
TheQuickBrownFoxJumpsOverTheLazyDog
输出:
NO
YES
题意:
如果一个字符串包含了所有的字符(a到z,不区分大小写),那么我们就说这是一个神奇的字符串。
现在,给你一个由大写和小写字母组成的字符串,判断其是否为神奇的字符串。
题解:
直接暴力,map或者用数组标记多可以。
代码:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int main(){
int n;
string str;
while(scanf("%d",&n)!=EOF){
cin>>str;
//int l = strlen(s);
set<int>s;
for(int i = 0; i < n; i ++){
if(str[i] >= 'A' && str[i] <= 'Z')
s.insert(str[i] - 'A');
else if(str[i] >= 'a'&&str[i] <= 'z')
s.insert(str[i] - 'a');
}
//cout<<s.size()<<endl;
if(s.size()==26)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
return 0;
}