Question: C++ Program: Write a program where a user gives a string and you translate it in the following two ways: 1- If you see a
C++ Program:
Write a program where a user gives a string and you translate it in the following two ways:
1- If you see a ' / ' in the string you add a ' [ ' to the begining of the string and a ' ] ' replacing the ' / ' you had. the second ' / ' you see you add a ' [ ' after the last ' ] ' and like before replace the ' / ' with ' ] ' . for example "AB/CD/EF/" becomes "[AB][CD][EF]"
The exception is, if there is only a single character before the string you don't put the brackets. for example "AB/C/DE/" becomes "[AB]C[DE]" or "A/BC/DE/" becomes "A[BC][DE]" or "AB/CD/E/" becomes "[AB][CD]E"
2- If you see a ' // ' you add a space to the string. so ' /// ' is two spaces , ' //// ' is three spaces and so on. multiple ' / ' also do the same thing as 1. for example "AB//CD/" becomes "[AB] [CD]" and "AB///CD/" becomes "[AB] [CD]" and so on. "////AB//CD/" becomes " [AB] [CD]".
More Examples: "D1J//J//8DH/D1J/" becomes "[D1J] J [8DH][D1J]"
"D1J/J//8DH/D1J/" becomes "[D1J]J [8DH][D1J]"
"D1J////J//8DH/D1J/" becomes "[D1J] J [8DH][D1J]"
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
