Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Find Element Index | Algorithms
C++ STL Containers and Algorithms

bookChallenge: Find Element Index

Завдання

Swipe to start coding

Write a function named findIndex that takes a std::vector<int> and an int value as arguments. Use the std::find algorithm from the Standard Library to search for the value in the vector. If the value is found, return its index; if not, return -1.

  • Use the std::find algorithm to perform the search.
  • Return the zero-based index of the found element.
  • Return -1 if the value is not present in the vector.

Рішення

solution.cpp

solution.cpp

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 2
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

close

Awesome!

Completion rate improved to 6.67

bookChallenge: Find Element Index

Свайпніть щоб показати меню

Завдання

Swipe to start coding

Write a function named findIndex that takes a std::vector<int> and an int value as arguments. Use the std::find algorithm from the Standard Library to search for the value in the vector. If the value is found, return its index; if not, return -1.

  • Use the std::find algorithm to perform the search.
  • Return the zero-based index of the found element.
  • Return -1 if the value is not present in the vector.

Рішення

solution.cpp

solution.cpp

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 2
single

single

some-alt