Wednesday, 18 May 2011

10035-Primary Arithmetic

#include<stdio.h>
int main()
{
    register unsigned long a,b,count,c;
    //freopen("in.txt","r",stdin);
    while(scanf("%lu%lu",&a,&b)&&(a||b))
    {
        count=c=0;
        while(a||b)
        {
            c=(a%10+b%10+c)/10;
            a=a/10;
            b=b/10;
            count=count+c;
        }
        if(!count)
            printf("No carry operation.\n");
        else if(!(count^1))
            printf("1 carry operation.\n");
        else
            printf("%d carry operations.\n",count);
    }
    return 0;
}

No comments:

Post a Comment