Kodewick
开始学 →
基础←→0 / 60

失物招领

#050基础常用算法字符串约 3 分钟

学校门口有个失物招领箱,box 里是捡到的东西。写 in_the_box(box, thing):用 find 找 thing,找到返回 true,没有返回 false。名字要一模一样,大小写也算。

示例
in_the_box({"umbrella", "scarf", "glove"}, "scarf")→True
in_the_box({"umbrella", "scarf"}, "hat")→False
函数bool in_the_box(const vector<string> &box, const string &thing)
main.cpp
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

bool in_the_box(const vector<string> &box, const string &thing) {
    // 在这里写:用 find 找 thing
    return false;
}
Ctrl + Enter 也能运行
结果

写好了先点「运行」试试示例,没问题再点「提交」。