//// In reverse order of words, the punctuation is in non-reverse order. example: // "ABC def GH. \ nabc def GH. "The Reverse Order is" GH. def ABC \ ngh. def ABC "// method: first put the letters in the sentence upside down, and then put each word letter upside down, as shown below. //. hg fed CBA \ n. hg fed CBA // GH. def ABC \ ngh. def ABC // # include <cstdlib> # include <cassert> # include <iostream> // invert word letters. // void reverse_word (char * word, size_t length) {assert (null! = Word); char ch; For (size_t I = 0; I <length/2; ++ I) {CH = word [I]; word [I] = word [length-1-I]; word [length-1-I] = CH ;}/// invert all letters in the sentence. // void reverse_sentence (char * sentence, size_t length) {size_t begin = 0; reverse_word (sentence, length); For (size_t offset = 0; offset <length; + offset) {If (''= sentence [offset]) {reverse_word (sentence + begin, offset-begin); begin = offset + 1 ;}} Rev Erse_word (sentence + begin, length-begin);} // invert the letters of all words in the paragraph. // void reverse_section (char * Section) {assert (null! = Section); // invert each sentence word. For (size_t begin = 0, offset = 0; '\ 0 '! = Section [offset]; ++ offset) {If ('\ n' = Section [offset] |' \ 0' = Section [offset]) {reverse_sentence (section + begin, offset-begin); begin = offset + 1 ;}} int main (void) {char section [] = "ABC def GH. \ nabc def GH. "; reverse_section (section); STD: cout <section <STD: Endl; return exit_success ;}