Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: TIMTOWTDI and other languages

by HollyKing (Pilgrim)
on Apr 29, 2002 at 22:04 UTC ( #162936=note: print w/ replies, xml ) Need Help??


in reply to TIMTOWTDI and other languages

Since I spend most of my day thinking in C++ I thought I would inject a little of that perspective. So here is a quick version that uses standard C++ only.

#include <iostream> #include <set> #include <algorithm> #include <iterator> int the_alphas[] = { 9, 4, 3, 2, 22, 13, 7, 140, 95, 278 }; int the_betas[] = { 8, 3, 4, 1, 278, 94, 15, 7, 19, 200 }; const int the_alphas_size = sizeof(the_alphas) / sizeof(the_alphas[0]) +; const int the_betas_size = sizeof(the_betas) / sizeof(the_betas[0]); int main(int argc, char** argv) { std::set<int> alphas(the_alphas, the_alphas + the_alphas_size); std::set<int> betas(the_betas, the_betas + the_betas_size); std::set<int> results; std::set_intersection(alphas.begin(), alphas.end(), betas.begin(), betas.end(), std::inserter(results, results.begin())); std::cout << "set_intersection: "; std::copy(results.begin(), results.end(), std::ostream_iterator<int>(std::cout, " ")); std::cout << std::endl; return 0; }

Owl looked at him, and wondered whether to push him off the tree; but, feeling that he could always do it afterwards, he tried once more to find out what they were talking about.


Comment on Re: TIMTOWTDI and other languages
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://162936]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (11)
As of 2014-10-21 10:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (100 votes), past polls