Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- char a, b, c;
- int s = 0;
- scanf("%c", &a);
- if (a == '!')
- {
- printf("0");
- return 0;
- }
- while (scanf("%c", &b))
- {
- if (a >= '0'&&a <= '9' && b >= '0' && b <= '9')
- s += ((a - '0') * 10 + (b - '0'));
- else if (a >= '0' && a <= '9' && (c <= '0' || c >= '9'))
- s += (a - '0');
- c = a;
- a = b;
- if (b == '!')
- break;
- }
- printf("%d", s);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement