學校門口有個失物招領箱,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;
}
寫好了先點「執行」試試示例,沒問題再點「提交」。