A - PG CodeForces - 520A

如果一个字符串包含了所有的字符(a到z,不区分大小写),那么我们就说这是一个神奇的字符串。
现在,给你一个由大写和小写字母组成的字符串,判断其是否为神奇的字符串。
Input
第一行包含一个整数n(1≤n≤100)表示字符串的长度。
第二行包含字符串,该字符串只包含大写和小写字母。
Output

如果是神奇的字符串,就输出YES,否则输出NO。

Sample Input
输入样例1:
12
toosmallword
 
输入样例2:
35
TheQuickBrownFoxJumpsOverTheLazyDog
Sample Output
输出样例1:
NO
 
输出样例2:
YES

思路:可以用strlwr()或者strupr()函数将字符串字母都变成小写或者大写。
再将字母-‘a'或者’A‘,从而将a~z转化为用0~25表示进而在判断。

#include<stdio.h>
#include<string.h>
int main()
{
	int i,n;
	char s[110];
	while(scanf("%d",&n)!=EOF)
	{
		int a[30]={0};
		scanf("%s",s);
		strupr(s);
		for (i=0;i<n;i++)
			a[s[i]-'A']++;
		for (i=0;i<26;i++)
			if (a[i]==0)
				break;
		if (i>=26)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}


猜你喜欢

转载自blog.csdn.net/qq_40912854/article/details/80865869