UVA 10035 - Primary Arithmetic

UVA Sep 1, 2020

Problem PDF

Solution:

#include
#include
int main()
{
    char a[20],b[20],e[20],d[20];
    int p,c,i,l,s,len,y,k,n,j;
    while(scanf("%s%s",a,b)==2)
    {
        k=(a[0]-'0');
        l=(b[0]-'0');
        if(k==0&&l==0)
        break;
        l=strlen(a);
        len=strlen(b);
        if(l>len)
        {
            y=l;
            n=l-len;
            for(i=0;i=0;i--)
        {
            s=(e[i]-'0')+(d[i]-'0');
            if(s>=10)
            {
               c++;
               e[i-1]++;
            }
        }
        if(c==0)
        printf("No carry operation.\n");
        else if(c==1)
        printf("1 carry operation.\n");
        else
        printf("%d carry operations.\n",c);
    }
    return 0;
}
https://github.com/Shipu/OnlineJudgeProblemSolutionWithCPlusPlus/tree/master/uva/10035/10035.cpp

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.