#include <stdio.h>
#include <stdlib.h>
#include<string.h>
char* reverseString(char* s);
int main()
{
char s[]="a.";
char *rs;
int len,i;
len=strlen(s);
printf("%d\n",len);
for(i=0;i<len;i++)
printf("%c",s[i]);
printf("\n");
rs=reverseString(s);
for(i=0;i<len;i++)
printf("%c",rs[i]);
return 0;
}
char* reverseString(char* s)
{
int len,i,n;
len=strlen(s);
n=(len-1)/2;
char tem;
for (i = 0; i <= n; i++)
{
tem = s[i];
s[i] = s[len - 1 - i];
s[len - 1 - i] = tem;
}
return s;
}
leetcode-反转字符串
最新推荐文章于 2024-09-22 13:47:41 发布