Search it!

2.3

3 votes
Grammar-Verified, Grammar-Verified, Easy
Problem

Consider a search engine that automatically recognizes escape sequences in the C language. If a string contains an escape sequence, the effect of the escape sequence on the string must be taken into consideration while printing the string. Each escape sequence performs a specific function:

  • \b - Backspace. Erases the last character
  • \n - Newline. Prints a new line

You are given multiple input lines containing one string each. The string may contain the escape sequences mentioned above.

Write a program to print the output after accounting for all the escape sequences.

Input format

  • The input consists of multiple lines. Each line contains a string.

Output format

Print the strings after applying the escape sequences.

Note:

Backspace does not take you to the previous line.

Constraints

1 Number of lines of the input 1000
1 Number of characters in one line 1000

Sample Input
This is sample tests\b \nThis is \bnew line
This is also a new line
Sample Output
This is sample test
This isnew line
This is also a new line
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

First '\b' moves cursor one position back and deletes letter s then '\n' shifts cursor to next line, then '\b' shifts cursor back deleting the space. Second line of input has zero occurrence of '\n' and '\b'.

Editor Image

?