Kodewick
Commencer à apprendre →
Bases←→0 / 60

Objets trouvés

#050Basesfind(…) != end()3 min

L’école a une boîte aux objets trouvés, et box en donne le contenu. Écris in_the_box(box, thing) : utilise find pour chercher thing, puis renvoie true s’il y est et false sinon. Les noms doivent être identiques, majuscules comprises.

Exemples
in_the_box({"umbrella", "scarf", "glove"}, "scarf")→True
in_the_box({"umbrella", "scarf"}, "hat")→False
La fonctionbool 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) {
    // ton code ici: cherche thing avec find
    return false;
}
Ctrl + Entrée lance aussi le code
Résultat

Exécuter teste les exemples. Quand ils sont bons, appuie sur Envoyer.