Guest User

Untitled

a guest
May 22nd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <set>
  4. #include <algorithm>
  5. using namespace std;
  6. set<char> c;
  7. void Add(set<char>& s)
  8. {
  9.     char a;
  10.     ifstream file ("example.txt",ios::in);
  11.     while(!file.eof())
  12.     {
  13.         file>>a;
  14.         if(s.insert(a).second)
  15.             cout<<"Inserted "<<a<<endl;
  16.         else
  17.             cout<<"Already exists"<<endl;
  18.     }
  19.     cout<<"Insertion complete!"<<endl;
  20.     system("pause");
  21.     system("cls");
  22. }
  23. void Print(set<char>& s)
  24. {
  25.     set<char>::iterator it;
  26.     for(it=s.begin();it!=s.end();it++)
  27.         cout<<*it<<" ";
  28. }
  29. set<char> alphabet;
  30. set<char> v;
  31. set<char>::iterator it;
  32. void AddAlpha(set<char>& s)
  33. {
  34.     char letter='a';
  35.     for(letter='a';letter<122;letter++)
  36.     {
  37.         s.insert(letter);
  38.     }
  39. }
  40. int main()
  41. {
  42.     AddAlpha(alphabet);
  43.     Add(c);
  44.     Print(c);
  45.     cout<<endl;
  46.     it=set_difference(c.begin(),c.end(),alphabet.begin(),alphabet.end(),v.begin());
  47.     cout<<"There is "<<v.size()<<" letters not used!"<<endl;
  48.     cout<<"\nThey are: "<<endl;
  49.     Print(v);
  50.     cout<<endl;
  51.     system("pause");
  52.     return 0;
  53. }
Add Comment
Please, Sign In to add comment