#include<stdio.h>
int main()
{
char src[100];
gets(src);
int len=0;
while(src[len]) //while(src[len++]);len--;
{
len++;
}
printf("%d\n",len);//输出字符串长度
int min=0;
int max=len-1;
while(min<max)
{
//一个汉字占两个字节大小
char temp=src[min];
src[min]=src[max-1];
src[max-1]=temp;
temp=src[min+1];
src[min+1]=src[max];
src[max]=temp;
max-=2;
min+=2;
}
printf("%s\n",src);
return 0;
}
字符串汉字逆序
最新推荐文章于 2022-08-11 15:46:15 发布