Advertisement
brsjak

Najdi go Zbirot - SP Lab3

Oct 25th, 2016
1,144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.34 KB | None | 0 0
  1. #include <stdio.h>
  2. int main(){
  3.     int sum=0,prev=0;
  4.     char c;
  5.     while(scanf("%c",&c)&&c!='!'){
  6.         if(c=='0'||c=='1'||c=='2'||c=='3'||c=='4'||c=='5'||c=='6'||c=='7'||c=='8'||c=='9'){
  7.             prev*=10+c-'0';
  8.         }
  9.         else{
  10.         sum+=prev;
  11.             prev=0;
  12.         }
  13.     }
  14.     sum+=prev;
  15.     printf("%d", sum);
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement