Advertisement
Guest User

Untitled

a guest
Jan 16th, 2018
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <set>
  4. #include <map>
  5.  
  6. using namespace std;
  7.  
  8. void wypisz_samogloski(map<char, int> mapa)
  9. {
  10.     string samogloski = "aeiou";
  11.     for (auto& para : mapa)
  12.     {
  13.         if (samogloski.find(para.first) != string::npos)
  14.         {
  15.             cout << para.second << "\n";
  16.         }
  17.     }
  18. }
  19.  
  20. void wprowadz_do_mapy(set<char> zbior)
  21. {
  22.     map<char, int> mapa;
  23.     for (auto& litera : zbior)
  24.     {
  25.         char lit = tolower(litera);
  26.         int poz = lit - 'a' + 1;
  27.         mapa.insert(make_pair(lit, poz));
  28.     }
  29.     wypisz_samogloski(mapa);
  30. }
  31.  
  32. string usun_powtorzenia(string str)
  33. {
  34.     set<char> zbior;
  35.     string nowy = "";
  36.     for (int i = 0; i < str.size(); i++)
  37.     {
  38.         if (zbior.find(str[i]) == zbior.end())
  39.         {
  40.             nowy += str[i];
  41.             zbior.insert(str[i]);
  42.         }
  43.     }
  44.     wprowadz_do_mapy(zbior);
  45.     return nowy;
  46. }
  47.  
  48. int main()
  49. {
  50.     string wejscie;
  51.  
  52.     cout << "Wpisz słowo: \n";
  53.     cin >> wejscie;
  54.  
  55.     cout << usun_powtorzenia(wejscie);
  56.  
  57.     return 0;
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement