问题描写:
写1个函数将i am a student 转化为 student a am i
解题思路:
//i am a student --->--> student a am i
#include<iostream>
using namespace std;
/*翻转函数--->利用交换*/
void words_reverse(char str[],int left,int right)
{
while(left < right)
{
str[left] += str[right];
str[right] = str[left] - str[right];
str[left] -= str[right];
left++;
right--;
}
}
int main()
{
char str[] = " student a am i";
/*找到数组的(最左侧)和(最右侧)后整体翻转*/
int left = 0;
int right = 0;
while(str[right] != '