早上看到好友未央的一篇博文《一道google的测试工程师笔试题》,内容如下:
这是去年面试google测试工程师的一道题,题目如下:
设计一个函数,使用任意语言,完成以下功能:
一个句子,将句子中的单词全部倒排过来,但单词的字母顺序不变。比如,This is a real world,输出结果为world real a is this. 他用C++很好的封装了一个函数实现了此功能,如下,更多信息请访问:http://www.itsbug.com/?p=208
C++版本:
#include
#include
using namespace std;
const char *Reverse(char *src);
char *pDst=NULL;
int main(int argc,char **argv)
{
cout << "please input your sentense:" << endl;
char pSrc[100];
memset(pSrc,0,100);
cin.getline(pSrc,100);
cout << Reverse(pSrc) << endl;
if (pDst != NULL)delete pDst;
return 0;
}
const char *Reverse(char *pSrc)
{
char *pPos =