学校门口有个失物招领箱,box 里是捡到的东西。写 in_the_box(box, thing):用 find 找 thing,找到返回 true,没有返回 false。名字要一模一样,大小写也算。
in_the_box({"umbrella", "scarf", "glove"}, "scarf")→Truein_the_box({"umbrella", "scarf"}, "hat")→Falsebool in_the_box(const vector<string> &box, const string &thing)#include <algorithm>
#include <string>
#include <vector>
using namespace std;
bool in_the_box(const vector<string> &box, const string &thing) {
// 在这里写:用 find 找 thing
return false;
}
写好了先点「运行」试试示例,没问题再点「提交」。