#include<stdio.h>
void main()
{
char str[] = {'a','b','c','d','e'};
char temp = {0};
int left = 0;
int right = sizeof(str)-1;
int count = 0;
while (left < right)
{
count++;
temp = str[right];
str[right] = str[left];
str[left] = temp;
left++;
right--;
}
printf("%s\r\n",str);
printf("runtime = %d\r\n",count); //查看一共做了几次运算
}
[C] 字符串数组翻转参考示例
最新推荐文章于 2022-04-09 10:52:24 发布