Starting from:

$30

COM1002 Lab 6 -Solved

Write a program that takes a character sequence and an index sequence as inputs and removes the characters in the given indexes with the given order:

Ex:          abcdef  2 0 3 -1

Keeping the given character sequence in an array:

 [‘a’, ‘b’,’c’,’d’,’e’,’f’]

AGer removing the character at the index 2, the array becomes:

 [‘a’, ‘b’,’d’,’e’,’f’]

Then remove the character at the index 0:

 [ ‘b’,’d’,’e’,’f’]

Then 3:

 [ ‘b’,’d’,’e’]

You are leG with this data. Please print the remaining characters to the output starMng from index 0:

                > bde

Input Format: 

<character sequence>[Space]{<indexes>[Space]}* -1

{.}* -> zero or more

All the index sequences will be terminated with -1.

Output Format: 

<remaining character sequence>\n

*You can assume that the character sequence will not exceed 100 characters.  

*Invalid indexes may be specified as well. You need to check if it is in the data range. 

More products