PAT 10-0 is ironic.

Source: Internet
Author: User

I wrote two implementations, the second of which was to refer to Yomman (http://www.cnblogs.com/yomman/p/4271949.html). My method (method one) is to use an array to hold the input string, the other array holds the first address of each word in the string, and then ... Method Two is to use OJ automatically at the end of the input to add the file terminator, I did not expect, and in their own compiler (dev-c++) can not be implemented, but it is a lot of concise, there is a little trouble, a little wasted space. The set requirements and code implementation are as follows, where method one is commented

/*NAME:COPYRIGHT:AUTHOR:DATE:03/04/15 07:59 Description: Given an English sentence, you are asked to write a program that reverses the order of all the words in the sentence. Input format: The test input contains a test case that gives a string with a total length of not more than 80 in a row. The string consists of several words and a number of spaces, where the word is a string of letters (case-sensitive), the words are separated by 1 spaces, and the input guarantees that there are no extra spaces at the end of the sentence. Output format: The output of each test case takes one line, and the output is reversed after the sentence. Input Sample: Hello World Here I Come output example: Come I here World Hello*/#include<stdio.h>//#include <string.h>//#include <stdbool.h>#defineMAX 80//refering to another ' sintMain () {//freopen ("In.txt", "R", stdin);//For Test    CharS[max/2][max +1]; intCNT; CNT=0;  while(SCANF ("%s", s[cnt++])! =EOF); CNT-=2;  while(CNT) printf ("%s", s[cnt--]); printf ("%s\n", s[cnt]);//fclose (stdin);//For Test    return 0;}/*void Inverse (char * s, int l); int main () {//Freopen ("In.txt", "R", stdin);//For Test char S[max + 1];        int l;    Gets (s);        L = strlen (s); Inverse (S, l);//fclose (stdin); for test return 0;}    void Inverse (char * s, int l) {char INDEX[L/2 + 1];    int I, CNT, TMP;        BOOL Head;    CNT = 0;    Head = true; for (i = 0; i < L; i++) {if (s[i]! = ") {if (head) {index[cnt++                ] = i;            Head = FALSE;    }} else head = true;        } do {tmp = index[--cnt];        while (s[tmp]! = "&& s[tmp]) Putchar (s[tmp++]);    if (CNT) printf ("");    }while (CNT); printf ("\ n");}*/

PAT 10-0 is ironic.

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.