fork download
  1. import java.io.*;
  2.  
  3. class GFG {
  4. public static void main (String[] args)throws IOException {
  5.  
  6. String s=br.readLine();
  7. String p="";
  8. int l=s.length();
  9. int c=0;
  10. for (int i=0;i<l;i++)
  11. {
  12. if(i==l-1&&s.charAt(i)=='1'){
  13. c++;
  14. if(c==6){p=p+"01";c=1;continue;}
  15. }
  16. //if(c==6)
  17. if(s.charAt(i)=='1')
  18. {
  19. if(c==5)
  20. {
  21. if(i%8!=0){p=p+'0';c=0;}
  22. }
  23. else c=0;
  24. }
  25. else c=0;
  26. p=p+s.charAt(i);
  27. }
  28. c=0;
  29. for(int i=0;i<p.length();i++)
  30. {
  31. if(c==8){System.out.println();c=0;}
  32. System.out.print(p.charAt(i));
  33. c++;
  34. }
  35. //System.out.println(p);
  36.  
  37. }
  38. }
Success #stdin #stdout 0.04s 2184192KB
stdin
111111000011111100
stdout
11111100
00111111
00