UVa 483 Word Scramble

 1  #include <stdio.h>
 2  #include <string>
 3  #include <iostream>
 4  #include <algorithm>
 5  #include <sstream>
 6  using namespace std;
 7  int main()
 8  {
 9      string line;
10      while(getline(cin,line))
11      {
12          string str[1000];
13          stringstream ss(line);
14          int x=0;
15          while(ss>>str[x]) x++;
16          for(int i=0;i<x;i++)
17          {
18              reverse(str[i].begin(),str[i].end());
19              cout<<str[i];
20              if(i!=x-1) cout<<' ';
21          }
22          cout<<endl;
23      }
24 
25 
26      return 0;

27  }

留言

這個網誌中的熱門文章

Things a Little Bird Told Me: Confessions of the Creative Mind

UVa 12970 Alcoholic Pilots