Wednesday, April 13, 2016

UVA Problem 10035: Primary Arithmetic-solution

Unknown
#include <stdio.h>
int main()
{  
    long x,y;
    int carry;
    int add;
    while(1)
    {
        scanf("%ld %ld",&x,&y);
        carry=0;
        add=0;
        if(x==0 && y==0)
            break;
        while(x!=0 ||y!=0)
        {
            if((x%10+y%10)+add>9)
            {
                carry++;
                add=1;
            }
            else
            {
                add=0;
            }
            x/=10;
            y/=10;
        }
        if(carry==0)
            puts("No carry operation.");
        else if(carry==1)
            printf("%d carry operation.\n",carry);
        else
            printf("%d carry operations.\n",carry);
    }
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,