Advertisement
sushmoyr

Bit stuffing

Jul 8th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     string data;
  6.     cin>>data;
  7.     string ans="";
  8.     int counter=0;
  9.     for(int i=0; i<data.size(); i++)
  10.     {
  11.         if(data[i]=='1')
  12.         {
  13.             counter++;
  14.             ans+=data[i];
  15.             if(counter==5)
  16.             {
  17.                 ans+='0';
  18.                 counter=0;
  19.             }
  20.         }
  21.         else
  22.             ans+=data[i],counter=0;
  23.     }
  24.     cout<<ans<<endl;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement