Reverse the whole string, then reverse each word. Using the reverseFixlen() above.void reverseWordsInSentence(char * sen) { int len = strlen(sen); reverseFixlen(sen, len); char * p = str; while (*p!=’\0’) { while (*p == ‘ ‘ && *p!=’\0’) p++; str = p; while (p!= ‘ ‘ && *p!=’\0’) p++; reverseFixlen(str, p-str); }}
共 1 个关于本帖的回复 最后回复于 2013-8-16 10:46