View Code of Problem 52

#include <stdio.h>
#include <string.h>
int len;
int fanxu(char c[100])
{
    int i,t;
    for(i=0;i<len/2;i++)
    {
        t=c[i];
        c[i]=c[len-i-1];//c[]最后一位是\0,不能用来交换。
        c[len-i-1]=t;
    }
    printf("%s",c);
}
int main()
{
    char c[100];
   // scanf("%s",c); 好像空格就结束了 
   gets(c);//直到换行结束 
    len=strlen(c);
    //printf("%d",len); 
    fanxu(c);
   return 0;
}

Double click to view unformatted code.


Back to problem 52