题目
IMUT 李文静《程序设计基础2020》题目集3-结构化程序设计技术
分析
搞清楚大小写字母的ASCII值,问题就迎刃而解
题解
#include<stdio.h>
int main(void)
{
char word=0;
// printf("%d %d\n",'a','A');
// printf("%d %d\n",'z','Z');
for(;(word=getchar())!='\n';)
{
if('A'<=word&&word<'Z')word=word+1+32;
else if(word=='Z')word=word-25+32;
else if('a'<=word&&word<'z')word=word+1-32;
else if(word=='z')word=word-25-32;
printf("%c",word);
}
printf("\n");
return 0;
}