NC21935. 判断是不是字母
描述
KiKi想判断输入的字符是不是字母,请帮他编程实现。
输入描述
多组输入,每一行输入一个字符。
输出描述
针对每组输入,输出单独占一行,判断输入字符是否为字母,输出内容详见输出样例。
示例1
输入:
A 6
输出:
A is an alphabet. 6 is not an alphabet.
C 解法, 执行用时: 1ms, 内存消耗: 416K, 提交时间: 2022-10-29 20:47:54
int main() { char c; while(~scanf("%c",&c)) { if(isalpha(c)) printf("%c is an alphabet.\n",c); else printf("%c is not an alphabet.\n",c); getchar(); } }
C++11(clang++ 3.9) 解法, 执行用时: 5ms, 内存消耗: 480K, 提交时间: 2018-12-27 14:50:21
#include<stdio.h> int main() {int a; while(~scanf("%s",&a)) if(a>=65&&a<=122) printf("%s is an alphabet.\n",&a); else printf("%s is not an alphabet.\n",&a); return 0; }
Python3(3.5.2) 解法, 执行用时: 38ms, 内存消耗: 3564K, 提交时间: 2018-12-25 02:03:35
while 1: try: x = input() print(x, 'is' + ('' if x.isalpha() else ' not'), 'an alphabet.') except: break