BC60. 判断是不是字母
描述
KiKi想判断输入的字符是不是字母,请帮他编程实现。
输入描述
多组输入,每一行输入一个字符。输出描述
针对每组输入,输出单独占一行,判断输入字符是否为字母,输出内容详见输出样例。示例1
输入:
A 6
输出:
A is an alphabet. 6 is not an alphabet.
C 解法, 执行用时: 1ms, 内存消耗: 304KB, 提交时间: 2021-07-21
#include <stdio.h> int main () {int ch=0; while(scanf("%c\n",&ch)!=EOF) { //if((ch>='A'&&ch<='Z')||(ch>='a'&&ch<='z')) if(isalpha(ch)) {printf("%c is an alphabet.\n",ch);} else {printf("%c is not an alphabet.\n",ch);} } return 0; }
C 解法, 执行用时: 1ms, 内存消耗: 308KB, 提交时间: 2021-09-07
#include <stdio.h> #include <ctype.h> int main() { int ch = 0; while(~scanf("%c\n",&ch)) { if(isalpha(ch)) printf("%c is an alphabet.\n",ch); else printf("%c is not an alphabet.\n",ch); } return 0; }
C 解法, 执行用时: 1ms, 内存消耗: 312KB, 提交时间: 2021-05-05
#include "stdio.h" int main() { char a; while(scanf("%c",&a)!=EOF){ getchar(); if((a>='A'&&a<='Z')||(a>='a'&&a<='z')) { printf("%c is an alphabet.\n",a); } else printf("%c is not an alphabet.\n",a); } return 0; }
C 解法, 执行用时: 1ms, 内存消耗: 316KB, 提交时间: 2020-12-20
#include<stdio.h> int main() { char a; while(scanf("%c",&a)!=EOF) { if(a<='Z'&&a>='A') printf("%c is an alphabet.\n",a); else if(a<='z'&&a>='a') printf("%c is an alphabet.\n",a); else if(a=='\n') continue; else printf("%c is not an alphabet.\n",a); } return 0; }
C 解法, 执行用时: 1ms, 内存消耗: 328KB, 提交时间: 2021-09-13
#include <stdio.h> int main(){ char a; while(scanf("%c\n",&a) != EOF){ if((a>='a'&&a<='z')||(a>='A'&&a<='Z')){ printf("%c is an alphabet.\n",a); } else{ printf("%c is not an alphabet.\n",a); } } }