Write a C or C++ program that require user to input only binary numbers. The program have
Question:
Write a C or C++ program that require user to input only binary numbers. The program have to detect any four consecutive 0’s in any space, after that the program have to automatically replace or substitute these four consecutive 0’s by one of these pattern (B00V) or (000V). To choose which one of these patterns to use depending on the previous digit that came before the consecutive 0’s. If a digit number 1 odd came before the consecutive 0’s, 000V pattern will be chosen. If two even digits like 11 came before the consecutive 0’s, b00v pattern will be chosen. To determine when it became odd or even like this example.
11 (we have two number of one so it is even).
111 (we have three numbers of one so it is odd). Note that the 1’s bits polarity always be opposite from the previous one. Example if the user input 1111 the output should be +-+-(we assume that it start with +).
In case of B00V, that the polarity of B must be the same as V (that is, –00– or +00+). To make the polarity of B00V to be like -00- or +00+ depending on the previous bits that came before the four consecutive 0’s.The polarity of B00V should be opposite of the last previous bit. The polarity of 000V should be the same as the last previous bit.
Example of the program: