用c语言编程。从键盘输入一行字符,若为小写字母,则转化为大写字母,若为大写字母,则转化为小写字母,

2024-12-03 12:19:54
推荐回答(1个)
回答1:

#include
#include
int main (void)
{
char ch[100];
int a = 0;
gets (ch);
while (ch[a] != '\0')
{
if (isupper (ch[a]))
ch[a] = tolower (ch[a]);
else if (islower (ch[a]))
ch[a] = toupper (ch[a]);
else
ch[a] += 1;
a++;
}
puts (ch);
return 0;
}
已测试,运行正常。