输入一个英文句子,翻转句子中的单词,要求单词内的字符顺序不变。
如:I am a student. 转换成 student. a am I
算法分析:
1、通过ReverseString(s,0,5)交换字符串第0位和第5位的字符,将I am a student. 转换成a am I student.
2、然后将字符向左移动一位变成 am I student.a
3、顺序向左移动7次就成为了student. a am I
#include "iostream"
#include <stdio.h>
using namespace std;
void ReverseString(char *s,int from,int to)
{
//交换from和to位置的字符
if(from<to)
{
char t = s[from];
s[from] = s[to];
&