fork(1) download
  1. #include <stdio.h>
  2. #include <string.h>
  3. void f(char*s) {
  4. int n=strlen(s)-2;
  5. printf("\ninput = %s\n", s);
  6. printf("output = ");
  7. if (*(++s)=='1')
  8. {
  9. printf("10");
  10. while(--n)
  11. putchar('0');
  12. printf("11\n");
  13. } else {
  14. putchar('1');
  15. while(*(++s)!='1') {
  16. putchar('0');
  17. --n;
  18. }
  19. putchar('1');
  20. while(--n)
  21. putchar('0');
  22. printf("1\n");
  23. }
  24.  
  25. }
  26. int main()
  27. {
  28. f("111");
  29. f("1110");
  30. f("101100");
  31. f("1000000000000000000000000000000000010100");
  32. return 0;
  33. }
  34.  
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
input  = 111
output = 1011

input  = 1110
output = 10011

input  = 101100
output = 110001

input  = 1000000000000000000000000000000000010100
output = 1000000000000000000000000000000000100001