西南科技大学OJ题 A + B 0015

A + B

 1000(ms)

 65535(kb)

 3303 / 14788

print the sum of two integer.

输入

 

two integer a and b.

输出

 

the sum of a and b.

样例输入

1 2

样例输出

3

#include<stdio.h>
#include<string.h>
int main()
{
    char a[500];
    char b[500];
    int d[2];
    int c[2];
    int n,m,sum1,sum2;
    while(scanf("%s %s",a,b)!=EOF)
    {
        n=strlen(a);
        m=strlen(b);
        if(n>=2)
        {
            d[0]=a[0]-'0';
            d[1]=a[1]-'0';
            sum1=d[0]*10+d[1];
        }
        else if(n==1)
        {
            sum1=a[0]-'0';
        }
        if(m>=2)
        {
            c[0]=b[0]-'0';
            c[1]=b[1]-'0';
            sum2=c[0]*10+c[1];
        }
        
        else if(m==1)
        {
            sum2=b[0]-'0';
        }
        sum1=sum1+sum2;
        printf("%d\n",sum1);
        
    }
}

猜你喜欢

转载自blog.csdn.net/qq_40593308/article/details/84499586
今日推荐