aboutsummaryrefslogtreecommitdiff
path: root/challenge-260/ulrich-rieke/cpp/ch-1.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'challenge-260/ulrich-rieke/cpp/ch-1.cpp')
-rwxr-xr-xchallenge-260/ulrich-rieke/cpp/ch-1.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/challenge-260/ulrich-rieke/cpp/ch-1.cpp b/challenge-260/ulrich-rieke/cpp/ch-1.cpp
new file mode 100755
index 0000000000..f9f90ce296
--- /dev/null
+++ b/challenge-260/ulrich-rieke/cpp/ch-1.cpp
@@ -0,0 +1,26 @@
+#include <iostream>
+#include <vector>
+#include <set>
+#include <iterator>
+#include <algorithm>
+
+int main( ) {
+ std::cout << "Enter some integers, separated by blanks, e to end!\n" ;
+ std::vector<int> numbers {std::istream_iterator<int>{std::cin} ,
+ std::istream_iterator<int>{}} ;
+ std::set<int> uniques( numbers.begin( ) , numbers.end( ) );
+ std::vector<int> frequencies ;
+ for ( auto i : uniques ) {
+ frequencies.push_back( std::count( numbers.begin( ) ,
+ numbers.end( ) , i ) ) ;
+ }
+ std::set<int> allFreq ( frequencies.begin( ) , frequencies.end( ) ) ;
+ if ( uniques.size( ) == allFreq.size( ) ) {
+ std::cout << 1 << '\n' ;
+ }
+ else {
+ std::cout << 0 << '\n' ;
+ }
+ return 0 ;
+}
+