题目:
题解:
char* reverseWords(char* s) {int length = strlen(s);char* ret = (char*)malloc(sizeof(char) * (length + 1));ret[length] = 0;int i = 0;while (i < length) {int start = i;while (i < length && s[i] != ' ') {i++;}for (int p = start; p < i; p++) {ret[p] = s[start + i - 1 - p];}while (i < length && s[i] == ' ') {ret[i] = ' ';i++;}}return ret;
}