البحث بـ std::optional — تحدي C++
اكتب findIndex(const std::vector<int>&, int) تُرجع std::optional<int> بموقع أول ظهور، أو std::nullopt. ثم describe(...) تُرجع "found at N" أو "not found".
std::optional<int> findIndex(const std::vector<int>& v, int target) {
return std::nullopt;
}
std::string describe(const std::vector<int>& v, int target) {
return "";
}حل هذا التحدي يرتبط بفتح دورة «C++ المتقدم» بحسابك.
ابدأ الحل