源代码:
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
int main()
{
char ch;
printf("请输入一个字符:\n");
while (1)
{
scanf("%c", &ch);
if (ch<'z'&&ch>'a')
{
ch = ch - 32;
printf("%c\n", ch);
}
else if (ch<'Z'&&ch>'A')
{
ch = ch + 32;
printf("%c\n", ch);
}
}
system("pause");
return 0;
}
运行结果: