Kodewick
Empieza a aprender →
Básico←→0 / 60

Objetos perdidos

#050Básicofind(…) != end()3 min

El colegio tiene una caja de objetos perdidos, y box lista lo que hay dentro. Escribe in_the_box(box, thing): usa find para buscar thing y devuelve true si está, false si no. Los nombres deben coincidir exactamente, mayúsculas incluidas.

Ejemplos
in_the_box({"umbrella", "scarf", "glove"}, "scarf")→True
in_the_box({"umbrella", "scarf"}, "hat")→False
La funciónbool 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) {
    // tu código aquí: busca thing con find
    return false;
}
Ctrl + Enter también ejecuta
Resultado

Ejecutar prueba los ejemplos. Cuando salgan bien, Enviar.