Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. char a, b, c;
  6. int s = 0;
  7. scanf("%c", &a);
  8. if (a == '!')
  9. {
  10. printf("0");
  11. return 0;
  12. }
  13. while (scanf("%c", &b))
  14. {
  15. if (a >= '0'&&a <= '9' && b >= '0' && b <= '9')
  16. s += ((a - '0') * 10 + (b - '0'));
  17. else if (a >= '0' && a <= '9' && (c <= '0' || c >= '9'))
  18. s += (a - '0');
  19. c = a;
  20. a = b;
  21. if (b == '!')
  22. break;
  23. }
  24. printf("%d", s);
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement