Question
#include <iostream>
#include <cmath>
#include <list>
using namespace std;
bool same_integral_part (double first, double second)
{
return ( int(first) == int(second) );
}
struct is_near
{
bool operator() (double first, double second)
{
return (fabs(first - second) < 5.0);
}
};
int main ()
{
double mydoubles[] = { 12.15, 2.72, 73.0, 12.77, 3.14, 12.77, 73.35, 72.25, 15.3, 72.25 };
list<double> mylist (mydoubles, mydoubles + 10);
mylist.sort();
mylist.unique();
mylist.unique (same_integral_part);
mylist.unique (is_near());
for (list<double> :: iterator it = mylist.begin(); it != mylist.end(); ++it)
cout << ' ' << *it;
cout << '\n';
return 0;
}
a.
2.72 12.15 72.25
b.
12.15 73.0 12.77
c.
73.35
d.
None of the mentioned
Posted under Object Oriented Programming Using C++
Engage with the Community - Add Your Comment
Confused About the Answer? Ask for Details Here.
Know the Explanation? Add it Here.
Q. What is the output of this program?
Similar Questions
Discover Related MCQs
Q. How the list containers are implemented?
View solution
Q. Which of the following does not support any insertion or deletion?
View solution
Q. What do container adapter provide to interface?
View solution
Q. What does the sequence adaptor provide?
View solution
Q. Which are presented in the container adaptors?
View solution
Q. In which context does the stack operates?
View solution
Q. Which operator is used in priority queue?
View solution
Q. What do associate containers implement?
View solution
Q. By using which of the following the elements in the associate container can
View solution
Q. How many items are presented in the associate container?
View solution
Q. How many instance are allowed by map and set while inserting a element into container?
View solution
Q. What do maps and sets support?
View solution
Q. What kind of library is Standard Template Library?
View solution
Q. To what type of object does the container can be instantiated?
View solution
Q. What type of class template is list?
View solution
Q. What type of access does deque and vector provide?
View solution
Q. Where does the vector add the item?
View solution
Q. Which are not full container classes in c++?
View solution
Q. What is the lifetime of the element in container?
View solution
Q. What do all STL containers define?
View solution
Suggested Topics
Are you eager to expand your knowledge beyond Object Oriented Programming Using C++? We've curated a selection of related categories that you might find intriguing.
Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!