首页 > 其他 > 详细

UVaOJ 112道题目-算数与代数

时间:2014-11-29 15:46:29      阅读:269      评论:0      收藏:0      [点我收藏+]

1、110501/10035 Primary Arithmetic (小学生算术)

注意输出格式

bubuko.com,布布扣
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
#include<algorithm>
using namespace std;
typedef long long lld;
lld a,b;
int main()
{
    while(scanf("%lld",&a)!=EOF)
    {
        scanf("%lld",&b);
        if(a==0&&b==0)
            break;
        int cnt=0;
        int tot=0;
        while(a!=0||b!=0)
        {
            if(a%10+b%10+cnt>=10)
            {
                cnt=1;
                tot++;
            }
            else
            {
                cnt=0;
            }
            a/=10;
            b/=10;
        }
        if(tot==0)printf("No ");
        else printf("%d ",tot);
        if(tot<=1)
            printf("carry operation.\n");
        else
            printf("carry operations.\n");
    }
    return 0;
}
View Code

 

UVaOJ 112道题目-算数与代数

原文:http://www.cnblogs.com/varcom/p/4130977.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!