字符串逆序存放

#include <stdio.h>    
#include<string.h>  
  
void f(char s[],int n)  
{     
    n=strlen(s);  
    for(int i=0,j=n-1;i<j;i++,j--)  
    {    
        char c=s[i];    
        s[i]=s[j];    
        s[j]=c;    
    }    
}    
    
int main()    
{     
    int n;
    char s[20]; 
    printf("请输入原字符串:");
    scanf("%s",s);  
    f(s,n);   
    printf("逆序存放后输出:%s",s);  
  
}    

猜你喜欢

转载自blog.csdn.net/inshixu/article/details/80174182