Dowemo

1009. ( 20 ) time limit 400 ms.
Memory limit 65536 kb
Code length limit 8000 b
program Standard yue,

Given a sentence of english, you need to write a program to reverse the order of all the words in the sentence.

input format: test input contai & a test case that gives a string of length less than 80 in one line. A string consists of a number of words and spaces, which are a string consisting of letters and letters, separated by 1 spaces, and input ensures no extra spaces at the end of.

output format: the output of each test case is a row, and the output of the sentence is output.

input sample:

Hello World Here I Come






output sample:

Come I Here World Hello







My solution.

#include<iostream>


using namespace std;


char a[80][80];


int main()


{


 int i=0,n;


 while(scanf("%s",&a[i])!=EOF)


 {


 n=i;


 ++i;


 }


 int flag=0;


 for(int j=n;j>=0;--j)//出错点:从n开始而不是n-1,共有n+1个数


 {


 if(flag)printf("");


 printf("%s",a[j]);


 flag=1;


 }


 return 0;


 } 












Copyright © 2011 Dowemo All rights reserved.    Creative Commons   AboutUs