




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































#include #include int main () { std::vector v1; v1.push_back(17); // LINE I std::cout< #include using namespace std; template ostream & print(T & start, T & end) { for(; start != end; ++start) cout<< *start<< " "; return cout;
empty_all()
clear()
there is no such method emptier() Question 41 pts What will happen when you attempt to compile and run the following code? #include #include #include #include using namespace std; template ostream & print(const T & start, const T & end) { T tmp = start; for(; tmp != end; ++tmp) { cout<< *tmp ; } return cout; } class A { public: int a; public: A(int a):a(a) {} }; void fill (const int table[], unsigned size, vector & v) { for(unsigned i = 0; i < size; ++i) { v.push_back(new A(table[i])); //LINE I } } ostream & operator<<(ostream & c, const A & o) { c << o.a << ", "; return c; } int main() { int tab[]={8, 7, 6, 4, 2, 1}; vector v1;
deque d; priority_queue q(d.begin(), d.end());
list_queue l; priority_queue q(l); deque d; priority_queue q(d);
Question 61 pts Which container class can be used as an underlying container for the stack? Choose all that apply. Group of answer choices deque vector list multimap Set Question 71 pts What will happen when you attempt to compile and run the following code? #include #include #include using namespace std; int main(){ int mynumbers[] = {8,9,7,6,4,1}; vector v(mynumbers, mynumbers+6); set s1(v.begin(),v.end()); s1.insert(v.begin(),v.end()); s1.insert(v.begin(),v.end());//LINE I set::iterator found = s1.find(9); for (; found!=s1.end(); ++found) cout << *found << ", "; return 0; } Group of answer choices program outputs: 0,
program outputs: 9,
runtime error at LINE I compilation error in LINE I Question 81 pts What will happen when you attempt to compile and run the following code? #include #include #include using namespace std; template void print(T start, T end) { while (start != end) { std::cout << *start << ", "; start++; } } int main(){ int mynumbers[] = {8,6,4,1}; vector v(mynumbers, mynumbers+6); set s(v.begin(),v.end()); for(int i=4; i>0; i ) { int x = *(s.begin()); //LINE I s.pop(); //LINE II v.push_back(i+x); } print(v.begin(), v.end()); print(s.begin(), s.end());cout< program outputs: 8, 6, 4, 1, 8, 6, 4, 1,
#include #include
#include using namespace std; int main(){ int mynumbers[] = { 8, 9, 7, 6, 4, 1, 6 }; multiset s1(mynumbers, mynumbers+6);//LINE I s1.insert(s1.find(9), 5); //LINE II for(multiset::iterator i=s1.begin();i!= s1.end(); i++) cout<<*i<<", "; return 0; } Group of answer choices runtime error at LINE I program outputs: 1, 4, 5, 6, 6, 7, 8, 9, program outputs: 1, 4, 5, 6, 7, 8, 9, program outputs: 1, 4, 5, 6, 7, 8, compilation error in LINE I compilation error in LINE II Question 111 pts What happens when you attempt to compile and run the following code? #include #include #include using namespace std; template void print(T start, T end) { while (start != end) { std::cout << start << ", "; start++; } } int main(){ int mynumbers[] = { 8, 9, 7, 6}; vector v(mynumbers, mynumbers+4); multiset s1(mynumbers, mynumbers+4); for(int i=4; i>0; i-- ) { double x=(s1.begin());//LINE I v.push_back(i+x); //LINE II
print(v.begin(), v.end()); cout< #include #include using namespace std; int main(){ int mynumbers[] = { 8, 9, 7, 6, 4, 1, 2}; vector v(mynumbers, mynumbers+6); multiset s1(v.begin(),v.end()); s1.insert(v.begin(),v.end()); s1.insert(v.begin(),v.end());//LINE I pair::iterator,multiset::iterator> range; range = s1.equal_range(6); while (range.first != range.second) { cout<<*range.first<<", "; //LINE II range.first++; } return 0; }
Group of answer choices
program outputs: zero, two, seven, seven, eight, eight, nine, nine,
CPP compilation error in LINE I program outputs: zero, two, two, seven, seven, eight, eight, nine, nine, program outputs: two, two, seven, seven, eight, eight, nine, nine, Question 141 pts What will happen when you attempt to compile and run the following code? #include #include #include #include #include using namespace std; class A { int a; public: A(int a):a(a) {} int getA() const { return a;} void setA(int a){ this->a = a;} bool operator < ( const A & b) const { return a v1(mynumbers, mynumbers + 6); set s1(mynumbers, mynumbers + 6); for_each(v1.begin(), v1.end(), doubler()); for_each(v1.begin(), v1.end(), myprinter());//LINE II for_each(s1.begin(), s1.end(), doubler()); for_each(s1.begin(), s1.end(), myprinter());//LINE III return 0; } Group of answer choices runtime error at LINE I