可以一直接受键盘字符,如果是小写字符就输出对应得大写字符,如果是大写字符就输出对应得小写字符,如果是数字就不输出
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
int main(){
char i;
char j;
while (i = getchar()){
if (i >= 'a'&&i <= 'z'){
j = i - 32;
printf("%c", j);
}
else if (i >= 'A'&&i <= 'Z'){
j = i + 32;
printf("%c", j);
}
}
system("pause");
return 0;
}
利用getchar()函数从键盘接受字符,用if条件语句进行转换,if中语句得转换可以用ascii来进行