Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <stdio.h>
  4. #include <vector>
  5. #include <sstream>
  6.  
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     int i, j;
  12.     string s = "Ala ma kota i trzy psy. Ela ma tylko jednego!";
  13.     string buffer;
  14.  
  15.     for(i = 0; i < s.size(); i++){
  16.         if(s[i] >= 'A' && s[i] <= 'Z') s[i] += 32;
  17.         else if(s[i] != ' ' && (s[i] > 'z' || s[i] < 'a')) s.erase(i, 1);
  18.     }
  19.  
  20.     stringstream ss(s);
  21.     cout << s;
  22.  
  23.     vector<string> G;
  24.  
  25.     while(ss >> buffer) G.push_back(buffer);
  26.     sort(G.begin(), G.end());
  27.  
  28.     cout << endl;
  29.  
  30.     for(i = 0; i < G.size(); i++) cout << G[i] << " ";
  31.  
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement