/* Exercise 4.1.2 Write a STL program that takes an arbitrary sequence of binary digits (integer values 0 and 1) from cin and stores them into a container. When receiving a value different from 0 or 1 from cin stop reading. Now, you should have a container storing a sequence of 0's and 1's. After finishing the read-process, apply a "bit-stuffing" algorithm to the container. Bit-stuffing is used to transmit data from a sender to a receiver. To avoid bit sequences in the data, which would erroneously be interpreted as the stop flag (here: 01111110), it is necessary to ensure that six consecutive 1's in the data are splitted by inserting a 0 after each consecutive five 1's. Hint: Complexity considerations (inserting in the middle of a vector takes linear time!) and the fact, that inserting into a vector can make all iterators to elements invalid should make you choose the STL container list. A list of integers is defined like a vector by listl; All operations explained in the vector section are provided for the list, too. Get an iterator to the first list element. As long as this iterator is different from the end() iterator increment the iterator and dereference it to get the appropriate binary value. Note that an element is always inserted before a specified iterator-position and that this insertion doesn't affect all the other iterators defined when using a list. */ #include using namespace std; void main() { list l; int input=0; list::iterator begin = l.begin(); list::iterator end = l.end(); cout<<"\nEnter a series of 0's and 1's. Terminate with any other integer\n"; while(input==1 || input==0) { cin>>input; if(input==1 || input==0) l.push_back(input); } /* // print values in list begin = l.begin(); end = l.end(); while(begin!=end) { cout<<*begin<