Answer the question
In order to leave comments, you need to log in
How to split an incoming string into groups of characters with a count of their position?
Hello!
There is a school problem in C ++, but there were difficulties with the solution. For now, I'm just guessing that you need to apply search_n in a loop.
Answer the question
In order to leave comments, you need to log in
No, you just need to read n characters and maintain the current character, the start index of the group, and the length of the group.
When you read the symbol, if it is not equal to the previous one, then output the group. If equal, then increase the length of the group. After the loop, don't forget to output the last group. Also, for convenience, initially you need to initialize your variables with a group of length 1 from the first character and start iterating from the second.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question