Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Practice with the Continue Keyword in C++ Loops | While Loop
C++ Loops

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

Завдання

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.

Рішення

solution.cpp

solution.cpp

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

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

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

Секція 1. Розділ 5
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

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

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

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

Завдання

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.

Рішення

solution.cpp

solution.cpp

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

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

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

Секція 1. Розділ 5
single

single

some-alt