

char* solve(char* str ) {
// write code here
// write code here
int j=strlen(str)-1;
int i=0;
char temp;
while(i<j)
{
temp=str[i];
str[i]=str[j];
str[j]=temp;
i++;
j–;
}
return str;
}
参考链接:
反转字符串
反转字符串函数实现与解析
本文介绍了如何使用C语言编写一个简单的字符串反转函数,通过交换字符串首尾字符实现。该函数遍历字符串,将首字符与末字符互换,然后依次进行,直到整个字符串反转。这是一个基础的字符串操作,常用于字符串处理和算法实现中。


char* solve(char* str ) {
// write code here
// write code here
int j=strlen(str)-1;
int i=0;
char temp;
while(i<j)
{
temp=str[i];
str[i]=str[j];
str[j]=temp;
i++;
j–;
}
return str;
}
参考链接:
反转字符串
168
5018
3546
2554

被折叠的 条评论
为什么被折叠?