An English sentence is emitted in reverse order by word. "I am a boy", for example, "Boy a Am I" after reverse discharge
All words are separated by a space, and the statement no longer contains other characters except the English letter
Interface description
/**
* Reverse sentences
*
* @param sentence original sentence
* @return the sentence after reversal
*/
public string Reverse (string sentence);
input Description: An English sentence is emitted in reverse order by word. output Description: Get the sentence in reverse order input example: I am a boy Output example: Boy a AM I program is as follows:
#include <stdio.h> #include <string.h>int main (void) { char str[1000] = {0}; char *p; Gets (str); while (p = strrchr (str, ')) { printf ("%s", p+1); At this point P points to the first letter of the last word, and the pointer goes to the back to add *p = ' + '; } printf ("%s", str); return 0;}
OJ question: sentence reversal