# 将其中每个单词的字母顺序翻转后打印输出到屏幕

<p>初始化一个字符数组为&#34;The best or nothing&#34;&#xff0c;并将其中每个单词的字母顺序翻转后打印输出到屏幕。要求&#xff1a;
1、字符数组的初始化在程序运行时由用户输入&#xff1b;
2、字符数组的翻转和结果输出功能通过函数实现&#xff1b;
3、字符数组不能定义成全局变量。</p>

## template

```cpp
#include <stdio.h>
#include <string>
void trans(char* p,int len)
{
	char* s = new char[len];
	memcpy(s,p,len);
	for (int i = 0; i < len; i++)
	{
		p[i] = s[len-1-i];
	}
	delete[] s;
	s = 0;
}
void transfun(char* p,int len)
{
	int start = 0;
	int i = 0;
	int shift = 0;
	while(i < len)
	{
		for (i = start; i < len;i++)
		{
			if(p[i] == ' ')
				break;
		}
		trans(p+shift,i-start);
		shift += i-start+1;
		start = i+1;
		i +=1;
	}
}
void output(char* p)
{
	printf("%s\n",p);
}
int main()
{
	char buf[1000] = {0};
	printf("请输入字符串：");
	gets(buf);
	transfun(buf,strlen(buf));
	output(buf);
	return 0;
}
```

## 答案

```cpp

```

## 选项

### A

```cpp

```

### B

```cpp

```

### C

```cpp

```