OJ question: sentence reversal

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.