What happens when you attempt to compile and run the following code?#include <iostream>#include <algorithm>#include <map>using namespace std;int main() {int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };map<int, int> m;for(int i=0; i < 10; i++) {m[i]=t[i];}pair<const int,int> p(5,5);map<int, int>::iterator it = find(m.begin(), m.end(), p); if (it != m.end()){cout<<it?>first<<endl;}else{cout<<"Not found!\n";}return 0;}Program outputs:
What happens when you attempt to compile and run the following code?#include <iostream>#include <algorithm>#include <vector>#include <set>using namespace std;void myfunction(int i) {cout << " " << i;}int main() {int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };set<int> s1(t, t+10);vector<int> v1(s1.rbegin(), s1.rend());swap_ranges(s1.begin(), s1.end(), v1.begin());for_each(v1.begin(), v1.end(), myfunction);for_each(s1.begin(), s1.end(), myfunction);return 0;}Program outputs:
What happens when you attempt to compile and run the following code?#include <iostream>#include <set>#include <list>using namespace std;int main(){int t[] ={ 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 };list<int>v(t, t+10);set<int> s1(v.begin(),v.end());if (s1.count(3) == 2) {s1.erase(3);}for(set<int>::iterator i=s1.begin();i!= s1.end(); i++) { cout<<*i<<" ";}return 0;}
What happens when you attempt to compile and run the following code?#include <vector>#include <iostream>#include <algorithm>#include <functional>using namespace std;template<class T>struct Out {ostream & out;Out(ostream & o): out(o){}void operator() (const T & val ) { out<<val<<" "; } };int Add(int a, int b) {return a+b;}int main() {int t[]={1,2,3,4,5,6,7,8,9,10};vector<int> v1(t, t+10);vector<int> v2(10);transform(v1.begin(), v1.end(), v2.begin(), bind2nd(ptr_fun (Add),1)); vector<int>::iterator it = find_if(v2.begin(), v2.end(),bind2nd(equal_to<int>(),10)); cout<<*it<<endl; return 0;}Program outputs:
What happens when you attempt to compile and run the following code?#include <iostream>#include <algorithm>#include <vector>#include <deque>using namespace std;void myfunction(int i) {cout << " " << i;}int main() {int t[] = { 10, 5, 9, 6, 2, 4, 7, 8, 3, 1 };deque<int> d1(t, t+10);vector<int> v1(d1.rbegin(), d1.rend());sort(d1.begin(), d1.end());swap_ranges(v1.begin(), v1.end(), d1.begin());for_each(v1.begin(), v1.end(), myfunction);for_each(d1.begin(), d1.end(), myfunction);return 0;}Program outputs:
What happens when you attempt to compile and run the following code?#include <iostream>#include <set>#include <vector>using namespace std;int main(){int t[] ={ 3, 4, 2, 1, 6, 5, 7, 9, 8, 0 };vector<int>v(t, t+10);multiset<int> s1(v.begin(),v.end());s1.insert(v.begin(),v.end());pair<multiset<int>::iterator,multiset<int>::iterator> range; range = s1.equal_range(6); while (range.first != range.second) { cout<<*range.first<<" "; range.first++;}return 0;}