你是否忘记进行行接受(不能直接scanf),或者忘记去除非字母和数字字符。
#include
#include
int main()
{
char s[256], *p, *q;
gets(s);
for(p=q=s; *p; ++p)
{
if(isalpha(*p) || isdigit(*p))
*q++ = *p;
}
*q = '\0';
for(p=s; *p; ++p)
{
if(isupper(*p))
*p = (*p<='M')*('A'+'M'-*p) + (*p>'M')*('Z'+'N'-*p);
else if(islower(*p))
*p = (*p<='m')*('a'+'m'-*p) + (*p>'m')*('z'+'n'-*p);
else
*p = '9'+'0'-*p;
}
puts(s);
}