题目为:键盘连续输入字符,回车结束。如果输入的是英文字符,则大小写互换;不是英文字符则输出。比如输入aZ8Bx+,则输出AzbX*
#include <stdio.h>
#include <math.h>
int main()
{
char x,c;
do
{
scanf("%c",&x);
if( x <= 'Z' && x >= 'A' )
{
c = x + 32;
printf("%c",c);
}
else if( x <= 'z' && x >= 'a' )
{
c = x - 32;
printf("%c",c);
}
else printf("*");
}while( x != '\n');
return 0;
}
输出结果为:
/shudb465sda
SHUDB*SDA
Process exited after 5.152 seconds with return value 0
请按任意键继续. . .
/
前面对应的上,但是最后都会多出一个星号 这种情况请问应该怎么解决?