fork download
  1. #include <stdio.h>
  2.  
  3. int main(int argc, char** argv)
  4. {
  5. int c;
  6. int x = 0;
  7. while((c = getchar()) != EOF)
  8. {
  9. if (c == '0' || c == '1')
  10. {
  11. x = x * 2 + c - '0';
  12. }
  13. }
  14. printf("%d\n", x);
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0.01s 1680KB
stdin
10101010
stdout
170