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.