#include<stdio.h>
#include<string.h>

int main()
{
    char str1[1001],str2[1001];
    int t,i,maxlen,len1,len2,k,num=1;
    scanf("%d",&t);
    getchar();
    while(t--)
    {
        int a[1001]={0},b[1001]={0},c[1001]={0};
        scanf("%s",str1);
         len1=strlen(str1);
        for(i=0;i<=len1-1;i++)
        {
           a[i]=str1[len1-i-1]-'0';
        }
        scanf("%s",str2);
         len2=strlen(str2);
        for(i=0;i<=len2-1;i++)
        {
           b[i]=str2[len2-i-1]-'0';
        }
        if(len1>len2)
             maxlen=len1;
        else
             maxlen=len2;
        k=0;
        for(i=0;i<=maxlen-1;i++)
        {
           c[i]=(a[i]+b[i]+k)%10;
           k=(a[i]+b[i]+k)/10;
        }
        if(k!=0)
         c[maxlen]=1;
         printf("Case %d:\n",num);
         num++;
         printf("%s + %s = ",str1,str2);
         if(c[maxlen]==1)
           printf("1");
         for(i=maxlen-1;i>=0;i--)
           printf("%d",c[i]);
         printf("\n");
         if(t>=1)
            printf("\n");
    }
    return 0;
}

杭电1002-A + B Problem II的更多相关文章

  1. 杭电 1002 A + B Problem II【大数相加】

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1002 解题思路:就是把大的数用数组存放起来,像小学的时候用竖式加法来算两个数相加那样算: 反思:思路很 ...

  2. Problem : 1002 ( A + B Problem II )

    经验总结:一定要注意输出的格式,字符的空格,空行,一定要观察清楚.如本题的最后一个输出结果后面没有空行.最后代码实现的时候需要判断一下,代码如下 !=n) cout<<endl; Prob ...

  3. 抓起根本(二)(hdu 4554 叛逆的小明 hdu 1002 A + B Problem II,数字的转化(反转),大数的加法......)

    数字的反转: 就是将数字倒着存下来而已.(*^__^*) 嘻嘻…… 大致思路:将数字一位一位取出来,存在一个数组里面,然后再将其变成数字,输出. 详见代码. while (a) //将每位数字取出来, ...

  4. A + B Problem II(杭电1002)

    /*A + B Problem II Problem Description I have a very simple problem for you. Given two integers A an ...

  5. HDU 1002 A + B Problem II(高精度加法(C++/Java))

    A + B Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  6. hduoj 1002 A + B Problem II

    原题链接:http://acm.hdu.edu.cn/showproblem.php?pid=1002 题目描述如下: A + B Problem II Time Limit: 2000/1000 M ...

  7. HDU 1002 A + B Problem II

    A + B Problem II   Time Limit: 1000MS      Memory Limit: 65536K Total Submissions: 16104    Accepted ...

  8. hdoj 1002 A + B Problem II

    A + B Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  9. hdoj 1002 A + B Problem II【大数加法】

    A + B Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  10. HDU 1002 A + B Problem II(大整数相加)

    A + B Problem II Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u De ...

随机推荐

  1. 阿里云的ubuntu server 12.04 下安装jdk和tomcat

    因为想自己在做个简单粗暴的小游戏,弄到朋友圈去,买了个阿里云服务,当时选的的ubuntu sever 12.04的os,恰巧朋友又委托一个小项目,所以先尝试搭建下环境. 首先,用putty或者SSH ...

  2. js方法和prototype

    JS中的方法可以分为三类 1.对象方法 2.类方法 3.原型方法 例: function People(name) { this.name=name; //对象方法 this.Introduce=fu ...

  3. Opencv读取各种格式图片,在TBitmap上面重绘

    //opencv读取图片 cv::Mat image; //const char *fileName = "HeadImage-UI/Photo-001.bmp"; const c ...

  4. using gulp

    原 荐 gulp构建前端工程 半张一块 发布时间: 2016/07/27 16:22 阅读: 895 收藏: 4 点赞: 4 评论: 2 摘要 Gulp 是一个自动化工具,前端开发者可以使用它来处理常 ...

  5. sdutoj 2152 Balloons

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2152 Balloons Time Limit: ...

  6. Java基础(44):ArrayList使用详解

    1.什么是ArrayList ArrayList就是传说中的动态数组,用MSDN中的说法,就是Array的复杂版本,它提供了如下一些好处:    a.动态的增加和减少元素    b.实现了IColle ...

  7. cocos2d对动画的各种操作

    瞬时动作:瞬时动作的基类是InstantAction 1.放置位置   CGPoint p = ccp(width,height); [sprite runAction:[CCPlace action ...

  8. demo02TextView

    main.xml----- /layout/activity_main.xml <RelativeLayout xmlns:android="http://schemas.androi ...

  9. 夺命雷公狗---node.js---17之项目的构建在node+express+mongo的博客项目2之一,二级路由

    然后我们就来开始搭建后台了... 不过后台我们可以来玩玩他的二级路由... 然后再去修改下他们的样式即可......修改方法和刚才那里的修改方法一样, 访问效果如下所示: OK,已经正常相识了

  10. ASP.NET MVC(二)

    休息一下还是继续ASP.NET MVC 的基础知识. 这篇文件我想和大家一起熟悉下ASP.NET MVC项目的目录结构及dll. 1. ASP.NET MVC 项目的目录结构 App_Data:  存 ...