题解 | #判断字母#
判断字母
https://www.nowcoder.com/practice/44d2d63103664913bc243d3836b4f341
#include <stdio.h>
#include<ctype.h>
int main() {
char c = 0;
scanf("%c", &c);
// //法一
// if (c >= 65 && c <= 90 || c >= 97 && c <= 122)
//法二
if(isalpha(c))
printf("YES\n");
else
printf("NO");
return 0;
}
法一是根据大小写字母的ASCII码值来判断,大写字母ASCII码值范围65~90,小写字母范围97~122
法二运用了字符函数isalpha(),参数是字母返回非0值,不是字母返回0。需要包含头文件<ctype.h>
#每日一题挑战#
查看7道真题和解析

广发银行公司氛围 23人发布