用c语言写一个从键盘上输入任意一个字母如果是大写字母则转换为小写字母后输出如果是小写字母则原样输出。设变量ch是char型变量。
#include <stdio.h>
int main() {
char ch;
printf("请输入一个字母:\n");
scanf("%c", &ch);
if (ch >= 'A' && ch <= 'Z') { // 大写字母
ch = ch + ('a' - 'A'); // 转换为小写字母
}
printf("转换后的字母为:%c\n", ch);
return 0;
}
原文地址: https://www.cveoy.top/t/topic/b5V9 著作权归作者所有。请勿转载和采集!