int main()
{
char str[100] = "hello world";
int len = 0;
while(str[len])
len++;
int min = 0;
int max = len - 1;
while (min < max)
{
char tmp = str[min];
str[min++] = str[max];
str[max--] = tmp;
}
printf ("%s\n", str);
return 0;
}
// 中文逆序
int main3()
{
char str[] = "你好世界";
int len = 0;
while(str[len])
len++;
int min = 0;
int max = len - 1;
char tmp;
while (min < max)
{
tmp = str[min];
str[min] = str[max-2];
str[max-2] = tmp;
tmp = str[min+1];
str[min+1] = str[max-1];
str[max-1] = tmp;
tmp = str[min+2];
str[min+2] = str[max];
str[max] = tmp;
min += 3;
max -= 3;
}
printf ("%d\n", sizeof(str));
printf ("%s\n", str);
return 0;
}
// 统计中英混合字符串长度
int main()
{
char str[] = "abc你好世界";
int i = 0;
int len = 0;
while (str[i])
{
if (str[i] < 0)
i += 2;
i++;
len++;
}
printf ("%d\n", sizeof(str));
printf ("%d\n", len);
return 0;
}