Public paste
fubard
By: j00 | Date: Nov 9 2007 21:11 | Format: C++ | Expires: never | Size: 988 B | Hits: 1292

  1. #include <iostream>
  2. #include <stack>
  3. #include <string>
  4. #include <fstream>
  5. #include <queue>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10.  
  11. {
  12.  
  13.     queue<string> s;
  14.     string word;          
  15.    
  16.  
  17.     ifstream in("input5.txt");
  18.    
  19.     while (getline(in,word))
  20.      {
  21.        s.push(word);
  22.     }
  23.    
  24.    
  25.     cout << "Number of words = " << s.size() << endl;
  26.  
  27.  
  28.  
  29.     while(!s.empty())
  30.     {
  31.      cout << s.front()<< "n";
  32.      s.pop();
  33. }
  34.  
  35.  
  36.  
  37.        
  38.         system("PAUSE");
  39.         return 0;
  40. }
  41.  
  42.  
  43. /* input
  44. Use stack and queue, from the Standard Template Library (STL), to reverse the words in this; sentence
  45. esU kcats dna eueuq, morf eht dradnatS etalpmeT yrarbiL (LTS), ot esrever eht sdrow ni siht ecnetnes.
  46. There are 1234 letters in this essay.
  47. Therefore, just do it
  48. esU kcats dna eueuq morf eht dradnatS etalpmeT yrarbiL (LTS) ot esrever eht sdrow ni siht ecnetnes
  49. esU kcats dna eueuq morf eht dradnatS etalpmeT yrarbiL ot esrever eht sdrow ni siht ecnetnes
  50. */