what is the output f the program?

what is the output of the program given below?

#include <iostream> 
#include <algorithm>
#include <vector>
using namespace std;
int main ()
{
    int first[] = {5, 10, 15, 20, 25};
    int second[] = {50, 40, 30, 20, 10};
    vector<int> v(10);
    vector<int> :: iterator it;
    sort (first, first + 5);
    sort (second, second + 5);
    it = set_union (first, first + 5, second, second + 5, v.begin());  
    v.resize(it-v.begin());
    for (it = v.begin(); it != v.end(); ++it)
        cout << ' ' << *it;
    cout << '\n';
    return 0;
}
40 50 5 10 15 all of the mentioned 20 25 30

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

Vishwa Tej
Mar 8, 2015

In this kind of style algorithm, We are finding the elements in the both the vector by using set_union function. Output: $ g++ style1.cpp $ a.out 5 10 15 20 25 30 40 50

Viswa, you really know all this.... or is this copy and paste from Internet. ... Brilliant doesn't support such things..... And cool I got 100 points easily. For I know this.. and thanks ... keep posting such problems...., wishing you success. .. Study for boards well.. Regards, Swaroop

Swaroop M. - 6 years, 3 months ago

Log in to reply

this is wht i should say u ... do u no all this? .... or is it whether u have used another account to see the answer and type the answer here... remember brilliant also doesn't support these kind of things... and obviously i no hw do the problem so i have posted it... anyways wish u the same.. all the best!

Vishwa Tej - 6 years, 3 months ago

Log in to reply

lol hahah i said it to you. how ik this :D and i dont use the other account -_-

I indented these lines

# 4 spaces, and now they show
# up as a code block.

print "hello world"

Swaroop M. - 6 years, 3 months ago

Log in to reply

@Swaroop M. wht do u mean... ?

Vishwa Tej - 6 years, 3 months ago

Log in to reply

@Vishwa Tej ok if u have done it then its good...

Vishwa Tej - 6 years, 3 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...