Created
November 16, 2017 19:14
-
-
Save Dropa/f63f0080453258cbc07a7d6df3e4a63b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <set> | |
#include <string> | |
#include <vector> | |
#include <iterator> | |
#include <algorithm> | |
using std::set; | |
using std::string; | |
using std::cin; | |
using std::cout; | |
using std::endl; | |
using std::vector; | |
using std::istream_iterator; | |
using std::back_inserter; | |
using std::less; | |
bool insert_new(const char& c); | |
int main() { | |
cout << "Insert characters, end with CTRL+Z (+ enter)" << endl; | |
vector<char> c, v; | |
copy_if(istream_iterator<char>(cin), | |
istream_iterator<char>(), | |
back_inserter(c), | |
[](const char c) { | |
return insert_new(c) == true; | |
}); | |
sort(c.begin(), c.end(), less<char>()); | |
for (auto i : c) { | |
cout << i;; | |
} | |
getchar(); | |
return 0; | |
} | |
bool insert_new(const char& c) { | |
static set<char> cc; | |
return cc.insert(c).second; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment