Advertisement
intsashka

Untitled

Sep 24th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.31 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <ctype.h>
  3.  
  4. int
  5. main(void)
  6. {
  7.     enum { CODE_ZERO = 48 };
  8.     unsigned int sum = 0;
  9.     int ch;
  10.     do {
  11.         ch = getchar_unlocked();
  12.         if(isdigit(ch)) {
  13.             sum += ch - CODE_ZERO;
  14.         }
  15.     } while(ch != EOF);
  16.     printf("%u\n", sum);
  17.     return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement