Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Challenge: Find Element Index | Algorithms
C++ STL Containers and Algorithms

bookChallenge: Find Element Index

Tarefa

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.

Solução

solution.cpp

solution.cpp

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 2
single

single

Pergunte à IA

expand

Pergunte à IA

ChatGPT

Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo

Suggested prompts:

What is Markdown and how is it used?

Can you show me some basic Markdown syntax?

What are the main features of Markdown?

close

Awesome!

Completion rate improved to 6.67

bookChallenge: Find Element Index

Deslize para mostrar o menu

Tarefa

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.

Solução

solution.cpp

solution.cpp

Switch to desktopMude para o desktop para praticar no mundo realContinue de onde você está usando uma das opções abaixo
Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 3. Capítulo 2
single

single

some-alt