1、思维导图

2、定义一个命名空间Myspace,包含以下函数:将一个字符串中的所有单词进行反转,并输出反转后的结果。例如,输入字符串为"Hello World",输出结果为"olleH dlroW",并在主函数内测试该函数。
#include <iostream>
#include <string>
using namespace std;
namespace Myspace
{
    void change();
}
void Myspace::change()
{
    std::string str;
    std::cout << "输入一串字符:" << std::endl;
    getline(cin,str);
    char* p = &str[0];
    char* q = p+str.length()-1;
    char* k = NULL;
    while(p < q)
    {
        char temp = *p;
        *p = *q;
        *q = temp;
        p++;
        q--;
    }
    p = q = &str[0];
    while(*q != '\0')
    {
       q++;
    }
    q--;
    while(p < q)
    {
        char temp = *p;
        *p = *q;
        *q = temp;
        p++;
        q--;
    }
    std::cout << "逆置结果为:" << str << std::endl;
}
using namespace Myspace;
int main()
{
    Myspace::change();
    return 0;
}



















