结果为什么会多出一个b
结果为什么会多出一个b#include <stdio.h>
int main()
{
char i;
while ((i=getchar())!='\n')
{
if((i<123&&i>96)||(i>=65&&i<91)) //判断是否为字母;
{
if (i>118&&i<=122) //判断是否为x,y,z;
{i-=23;
printf("%c",i);
}
else if (i>86&&i<91)//判断是否为X,Y,Z;
{i-=23;
printf("%c",i);
}
else i+=3; //处x,y,z,X,Y,Z以外字母偏移3;
printf("%c",i);
}
else printf("%c",i); //输出字母以外的字符;
}
}
结果:
yanghaiping182;
bbdqjkdlslqj182;
--------------------------------
Process exited after 19.4 seconds with return value 0
请按任意键继续. . .
因为你的程序中第17和18行的两句应该用{}括起来,这两句同属于else语句块。而你没有将之括起来,所以说遇到xyz或者XYZ都会多打印一遍。
页:
[1]