d392

輸入說明 :

每行都有一大堆数字,但都很kind,不会刁难你的,用 longint 就可以了,而且都不是负数。

輸出說明 :

输出这一行中出现的所有的数字的和并换行。

用sscanf來做

#include<stdio.h>
int main()
{
    int n,l;
    int sum=0;
    char c[10000];
    char *p;

    while(gets(c))
    {
        p=c;
        while(sscanf(p,"%d%n",&n,&l)==1)
        {
            sum+=n;
            p+=l;
        }
        printf("%d\n",sum);
        sum=0;
    }
}