m*****m 发帖数: 242 | 1 std::vector items;
Referring to the sample code above, how do you remove all elements from the
items
collections that are greater than 50?
a. items.erase(std::remove_if(items.begin(), items.end(), std::bind2nd(std::
greater(), 50)), items.end());
b. std::remove_if(items.begin(), items.end(), std::greater(50));
c. items.erase(std::remove_if(items.begin(), items.end(), std::bindlst(std::
less_equal(), 50)), items.end());
d. items.remove_if(items.begin(), items.end(), std::bind2 |
e****d 发帖数: 333 | |
t****t 发帖数: 6806 | 3 选择题还不会查手册...试一试也行啊
the
int
【在 m*****m 的大作中提到】 : std::vector items; : Referring to the sample code above, how do you remove all elements from the : items : collections that are greater than 50? : a. items.erase(std::remove_if(items.begin(), items.end(), std::bind2nd(std:: : greater(), 50)), items.end()); : b. std::remove_if(items.begin(), items.end(), std::greater(50)); : c. items.erase(std::remove_if(items.begin(), items.end(), std::bindlst(std:: : less_equal(), 50)), items.end()); : d. items.remove_if(items.begin(), items.end(), std::bind2
|
e****d 发帖数: 333 | |
m*****m 发帖数: 242 | 5 去一个当地的小公司面试, 上来就给发了一些题目做,我当时无意中多拿了一份就带
回来了
【在 e****d 的大作中提到】 : 你这些题都是哪来的呢?谢了。
|
s******n 发帖数: 21 | 6 Erase-Remove Idioms
【在 e****d 的大作中提到】 : 你这些题都是哪来的呢?谢了。
|
e****d 发帖数: 333 | 7 你还是编程试试吧。a也好像行。
【在 m*****m 的大作中提到】 : 去一个当地的小公司面试, 上来就给发了一些题目做,我当时无意中多拿了一份就带 : 回来了
|
e****d 发帖数: 333 | 8 a?
【在 s******n 的大作中提到】 : Erase-Remove Idioms
|
S*********g 发帖数: 5298 | 9 it is one item in the book "effective C++ "
【在 e****d 的大作中提到】 : a?
|
e****d 发帖数: 333 | 10 Thanks. actually, i read that one some time ago in my spare time.
Looks like more than once is a must.
you mean more effective?
【在 S*********g 的大作中提到】 : it is one item in the book "effective C++ "
|
|
|
m*****m 发帖数: 242 | 11 有点迷惑是因为,题目中说是remove, how do you remove all elements from the
items
collections that are greater than 50?
erase就是eliminate了, 对吧?
选项a是 先remove 再 eliminate 那些大于50的元素
我的意思是remove_if 只是remove, 原来的vector的size不变
erase 是真正的eliminate 那些elements, 改变vector的size。
我不确定原题到底是啥意思?
【在 s******n 的大作中提到】 : Erase-Remove Idioms
|
e****d 发帖数: 333 | 12 i guess you mean effective STL right?item 47.
【在 S*********g 的大作中提到】 : it is one item in the book "effective C++ "
|
S*********g 发帖数: 5298 | 13 yes, effective STL, not C++
【在 e****d 的大作中提到】 : i guess you mean effective STL right?item 47.
|
m****o 发帖数: 114 | 14 brainbench has a lot of stuff like this.
【在 e****d 的大作中提到】 : 你这些题都是哪来的呢?谢了。
|
g**o 发帖数: 29 | 15 and you type them?
i saw this exact question in an online test before
【在 m*****m 的大作中提到】 : 去一个当地的小公司面试, 上来就给发了一些题目做,我当时无意中多拿了一份就带 : 回来了
|