Seal_of_approval

PrQueue

Jun 30th, 2015
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 KB | None | 0 0
  1. #include <queue>
  2. #include <fstream>
  3. #include <iostream>
  4. #include <cstdio>
  5. #include <cctype>
  6. #include <string>
  7. #define IS_DELIM (c == ' ' || c == '\t' ||  c == '\n')
  8.  
  9. using namespace std;
  10.  
  11. int main(void) {
  12.     ifstream in ("input.txt");
  13.     ofstream out ("output.txt");
  14.     queue<string> small;
  15.     queue<string> big;
  16.     queue<char> current;
  17.    
  18.     char c;
  19.     while (in >> noskipws >> c)
  20.     {
  21.         current.push(c);
  22.     }
  23.  
  24.     bool begin = true;
  25.     string s;
  26.     while (current.size())
  27.     {
  28.         c = current.front();
  29.         current.pop();
  30.         if (!IS_DELIM)
  31.         {
  32.             begin = false;
  33.             s += c;
  34.         }
  35.         else if (s.size())
  36.         {
  37.                 if (islower(s[0])) small.push(s);
  38.                 else big.push(s);
  39.                 s.clear();
  40.                 begin = true;
  41.         }
  42.     }
  43.  
  44.     while (small.size())
  45.     {
  46.         out << small.front() << " ";
  47.         small.pop();
  48.     }
  49.  
  50.     while (big.size())
  51.     {
  52.         out << big.front() << " ";
  53.         big.pop();
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment