演示版本
VS2013
- 判断字母是否大写
实例说明:
输入一个字母,判断是否为大写字母。如果是,则提示"uppercase-letter!",否则提示"other-letter!"。
利用if语句判断输入字符的ASCII码是否在65~90这个范围内,如果在,则该字符是大写字母;否则不是大写字母。
#include <stdio.h> #include <math.h> int main() { char c; printf("输入一个字母:\n"); c = getchar(); if (c >= 65 && c <= 90) printf("uppercase letter!\n"); else printf("other letter!\n"); return 0; }
阿飞
2021年8月6日