Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2022-08-13 21:04 GMT
Find Nodes?
    Voting Booth?

    No recent polls found