SHARE
TWEET

Untitled

a guest Nov 12th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top