求助C++ 中的 char * reverse()

来源:百度知道 编辑:UC知道 时间:2024/05/29 06:27:48
题目是“we love this game ”。利用reverse函数将其变为“game this love we ”,注意程序的效率及完整性
非常感谢,不过可能是我的表述有问题,首先reverse函数已给出,且参数只有一个,是利用函数实现将字符串we love this game变化,直接使用的话结果不是game this love we ,小弟不太懂,觉得应该调用两次,一次将该句作为整体,一次是指针数组调用

转:
//////////////////////////////////////////////////////////////////////
//
// Compile options needed: /GX
//
// reverse.cpp : Illustrates how to use the reverse function.
//
// Functions:
//
// reverse - Reverse the items in a sequence.
//
// Written by Kalindi Sanghrajka
// of Microsoft Product Support Services,
// Software Core Developer Support.
// Copyright (c) 1996 Microsoft Corporation. All rights reserved.
//////////////////////////////////////////////////////////////////////

// disable warning C4786: symbol greater than 255 character,
// okay to ignore

#pragma warning(disable: 4786)

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>

#if _MSC_VER > 1020 // if VC++ version is > 4.2
using namespace std; // std c++ libs implemented