fork download
  1. #include <iostream>
  2. using namespace std;
  3. #define MAX 100
  4.  
  5. int main() {
  6. // your code goes here
  7. long long int a[MAX], b[MAX],f=11111;
  8. int n,i,j=1,count;
  9. //cout<<"enter no of data packets:";
  10. cin>>n;
  11. a[0]=f;
  12. for(i=0;i<n;i++)
  13. {
  14. cin>>a[j];
  15. j++;
  16. a[j]=f;
  17. j++;
  18. }
  19. cout<<"after stuffing:";
  20. for(i=0;i<(2*n+1);i++)
  21. cout<<a[i]<<endl;
  22. count=0;
  23. cout<<"destuffing";
  24. for(i=0;i<(2*n+1);i++)
  25. {
  26. if(a[i]==f)
  27. count++;
  28. else
  29. cout<<a[i]<<endl;
  30. }
  31. cout<<"no of data packets:"<<(count-1);
  32. return 0;
  33. }
Success #stdin #stdout 0s 15240KB
stdin
4
101011
100110
110010
111110
stdout
after stuffing:11111
101011
11111
100110
11111
110010
11111
111110
11111
destuffing101011
100110
110010
111110
no of data packets:4