diff options
| author | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-09-21 13:19:56 +0100 |
|---|---|---|
| committer | Mohammad S Anwar <mohammad.anwar@yahoo.com> | 2022-09-21 13:19:56 +0100 |
| commit | 06903e154012dd6da0cedbc803d702fea9334492 (patch) | |
| tree | 16e5bf291d393469f70af7ac5a053fba0063e998 /challenge-183/ulrich-rieke/cpp/ch-1.cpp | |
| parent | e66131f9e712f8da717bb0694dd5b67f06424666 (diff) | |
| download | perlweeklychallenge-club-06903e154012dd6da0cedbc803d702fea9334492.tar.gz perlweeklychallenge-club-06903e154012dd6da0cedbc803d702fea9334492.tar.bz2 perlweeklychallenge-club-06903e154012dd6da0cedbc803d702fea9334492.zip | |
- Added solutions by Ulrich Rieke.
Diffstat (limited to 'challenge-183/ulrich-rieke/cpp/ch-1.cpp')
| -rw-r--r-- | challenge-183/ulrich-rieke/cpp/ch-1.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/challenge-183/ulrich-rieke/cpp/ch-1.cpp b/challenge-183/ulrich-rieke/cpp/ch-1.cpp new file mode 100644 index 0000000000..b6496b0a06 --- /dev/null +++ b/challenge-183/ulrich-rieke/cpp/ch-1.cpp @@ -0,0 +1,34 @@ +#include <utility> +#include <algorithm> +#include <vector> +#include <iostream> +#include <set> + +int main( ) { + std::cout << "Enter some numbers sequentially in pairs ( 0 to end )!\n" ; + std::pair<int , int> input ; + std::vector<std::pair<int , int>> allInput ; + std::set<std::pair<int , int>> seenSoFar ; + int a ; + int b ; + std::cin >> a ; + std::cout << "second number?\n" ; + std::cin >> b ; + while ( b != 0 ) { + input = std::make_pair( a , b ) ; + allInput.push_back( input ) ; + std::cout << "First integer:\n" ; + std::cin >> a ; + std::cout << "second integer ( 0 to end ):\n" ; + std::cin >> b ; + } + std::cout << '[' ; + for ( auto it = allInput.begin( ) ; it != allInput.end( ) ; ++it ) { + if ( seenSoFar.find( *it ) == seenSoFar.end( ) ) { + std::cout << '[' << it->first << ',' << it->second << "]," ; + seenSoFar.insert( *it ) ; + } + } + std::cout << ']' << std::endl ; + return 0 ; +} |
