Enter an English sentence, flipping the order of the words in the sentence, but the order of the characters in the word does not change. Words are separated by spaces in sentences.
for simplicity, punctuation is treated like ordinary letters.
For example, convert "I am a student" to "Student a AM I".
#include <stdio.h> #include <string.h>//reversal string char* Reverse (char *str, int len) {if (str = = NULL | | Len &L t;= 0) return str; Char *plast = str + len-1; char *pbegin = str; while (Pbegin < pLast) {char temp = *pbegin; *pbegin = *plast; *plast = temp; + + Pbegin; --PLast; } return str;} Reversal sentence char * reversesentence (char *str) {if (str = = NULL) {return str; }//Reverses the entire sentence Reverse (str, strlen (str)); Reverses each word char *pbegin = str; char *pend = str; while (*pend! = ')} {while (*pend! = ' && *pend! = ') ++pend; Reversal Word Reverse (pbegin, Pend-pbegin); if (*pend = = ' + ') {break; } ++pend; Pbegin = pEnd; } return str;} int main () {char str1[] = ""; Char str2[] = "a"; Char str3[] = "ABC"; Char str4[] = "I am a student"; if (strcmp (Reversesentence (STR1), "") = = 0 || strcmp (Reversesentence (STR2), "a") = = 0 | | strcmp (Reversesentence (STR3), "abc") = = 0 | | strcmp (Reversesentence (STR4), "Student A AM I") = = 0) {printf ("Reverse sentence ok\n"); } return 0;}