Invert word xynuoj 1626 (processing of strings)

Source: Internet
Author: User
Tags strlen
Invert Words

Time limit: 1 Sec memory limit: MB
Submissions: 22 Resolution: 6
The status of your title: Completed
Submitted State [Discussion Version] Title Description

Restores each inverted word in the input. input

The input contains samples of several sets of test specimens. The first behavior is an integer t, which represents the number of test samples followed by a T test sample.
Each test sample occupies one line and contains multiple words. A line has a maximum of 1000 characters. Output

For each test sample, you should output the converted text. Sample Input

2
I Evol!ANIHC
Olleh!dlrow Sample Output

I love china!
Hello world!

 #include <stdio.h> #include <string.h> int main () {int t;
    scanf ("%d", &t); GetChar ();
        Absorbs newline characters while (t--) {char c[1000];
        Gets (c);
                for (int i=0;i<=strlen (c); i++) {if (c[i]== ' | | c[i]== ')//Meet space or terminator, reverse output Word {
                int j=i-1; while (J!=-1 && c[j]!= ")//here is && instead of | |
                    , meet the space or subscript as-1, a word output end {printf ("%c", C[j]); 
                j--;
                } if (I==strlen (c))//All words have been output, newline printf ("\ n");
            else printf ("");
}}} return 0; }

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.