Kodewick
開始學 →
基礎←→0 / 86

失物招領

#050基礎find(…) != end()約 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 也能執行
結果

寫好了先點「執行」試試示例,沒問題再點「提交」。