Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- vector <int> unosBinarnihZnamenki()
- {
- vector <int> nekiVektor;
- int unos=0;
- cout<<"Unesi"<<endl;
- while(unos==0 || unos ==1)
- {
- cin>>unos;
- nekiVektor.push_back(unos);
- }
- nekiVektor.pop_back();
- return nekiVektor;
- }
- vector <int> stuffing_bit(vector <int> v)
- {
- int broj_asova=0;
- vector <int>::iterator it=v.begin();
- for(it=v.begin();it!=v.end();it++)
- {
- if(*it==1)
- {
- broj_asova+=1;
- }
- else
- {
- broj_asova=0;
- }
- if(broj_asova==5)
- {
- it++;
- v.insert(it,0);
- it--;
- broj_asova=0;
- }
- }
- return v;
- }
- int main()
- {
- vector <int> v=unosBinarnihZnamenki();
- stuffing_bit(v);
- for(int i=0;i<v.size();i++)
- {
- cout<<v[i]<<" ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement