Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprende Challenge: Practice with the Continue Keyword in C++ Loops | While Loop
C++ Loops

bookChallenge: Practice with the Continue Keyword in C++ Loops

Tarea

Swipe to start coding

The ID string has been corrupted and is currently saturated with exclamation marks (!). You were chosen to restore the original data it was holding.

All the code should be implemented inside the fixId function.

  1. Initialize the variable fixed_id as an empty string.
  2. Initialize the variable index as 0. This will act as an iterator to track the current position in the corrupted_id string.
  3. Use a while loop to iterate through the string until index reaches the size of the string. You can get the size of the string using the length() method.
  4. Inside the loop, check if the current character is '!'. If it is, increment index and continue to skip adding it.
  5. If the character is not '!', append it to fixed_id.
  6. Increment index by one on each iteration.
  7. After the loop finishes, return fixed_id as the cleaned ID.

Solución

solution.cpp

solution.cpp

¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 5
single

single

Pregunte a AI

expand

Pregunte a AI

ChatGPT

Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla

Suggested prompts:

Can you explain this in simpler terms?

What are some examples related to this topic?

Where can I learn more about this?

close

Awesome!

Completion rate improved to 9.09

bookChallenge: Practice with the Continue Keyword in C++ Loops

Desliza para mostrar el menú

Tarea

Swipe to start coding

The ID string has been corrupted and is currently saturated with exclamation marks (!). You were chosen to restore the original data it was holding.

All the code should be implemented inside the fixId function.

  1. Initialize the variable fixed_id as an empty string.
  2. Initialize the variable index as 0. This will act as an iterator to track the current position in the corrupted_id string.
  3. Use a while loop to iterate through the string until index reaches the size of the string. You can get the size of the string using the length() method.
  4. Inside the loop, check if the current character is '!'. If it is, increment index and continue to skip adding it.
  5. If the character is not '!', append it to fixed_id.
  6. Increment index by one on each iteration.
  7. After the loop finishes, return fixed_id as the cleaned ID.

Solución

solution.cpp

solution.cpp

Switch to desktopCambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
¿Todo estuvo claro?

¿Cómo podemos mejorarlo?

¡Gracias por tus comentarios!

Sección 1. Capítulo 5
single

single

some-alt