牛客题霸-算法篇题目描述 写出一个程序,接受一个字符串,然后输出该字符串反转后的字符串。

牛客题霸-算法篇题目描述
写出一个程序,接受一个字符串,然后输出该字符串反转后的字符串。(字符串长度不超过1000)

示例1

输入

"abcd"

返回值

"dcba"
void swap(int x,int y){
    
    
    int temp=x;
    x=y;
    y=temp;
}
char* solve(char* str ) {
    
    
    int i=0,j=strlen(str)-1;
    while(i<j) swap(str[i++],str[j--]);
    return str;
    
}

猜你喜欢

转载自blog.csdn.net/qq_53749266/article/details/114897571
今日推荐