Page 1 of 1

What happens when you attempt to compile and run the following code?#include <iostream>#include <set>#include <list>usin

Posted: Wed Aug 03, 2022 9:20 am
by answerhappygod
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;}

A. program outputs: 1 2 3 4 5
B. program outputs: 1 2 4 5
C. program outputs: 1 1 2 2 3 4 4 5 5
D. program outputs: 1 1 2 3 3 4 4 5 5 E. compilation error