全部内容来自《剑指offer》。
题目一:
输入一个英文句子,翻转句子中单词的顺序,但单词内字符的顺序不变。为简单起见,标点符号和普通字符一样处理。例如输入字符串“I am a student.”,则输出
“student. a am I”。
ANSWER:
void reverse(char *pBegin, char *pEnd) { if (pBegin == NULL || pEnd == NULL) return; while (pBegin < pEnd) { char tmp = *pBegin; *pBegin = *pEnd; *pEnd = tmp; pBegin++; pEnd--; } } char* reverseSentence(char *pDate) { if (pDate == NULL) return NULL; char *pBegin = pDate; char *pEnd = pDate; while (*pEnd != '