不适用任何变量将字符串逆序
比如:"abcd" =》 "dcba"
这时候我们就要分析一下这个字符串本身
"adcd" =》 它是由 a b c d \0 五个字符构成的
那我们不能使用任何变量就只能利用这个 \0 了
分析:
实现:
#include <stdio.h>
#include <stdlib.h>
int main()
{
char str[] = { "abcd" };
printf("%s\n\n", str);
str[4] = str[0];
str[0] = str[3];
str[3] = str[4];
str[4] = str[1];
str[1] = str[2];
str[2] = str[4];
str[4] = '\0';
printf("%s\n\n", str);
system("pause");
return 0;
}
嘻嘻~~~
思路比较简单~~~