Primary Arithmetic


Time Limit:
2 Seconds      Memory Limit:
65536 KB


Children are taught to add multi-digit numbers from right-to-left one digit at a time. Many find the "carry" operation - in which a 1 is carried from one digit position to be added to the next - to be a significant challenge.
Your job is to count the number of carry operations for each of a set of addition problems so that educators may assess their difficulty.

Input

Each line of input contains two unsigned integers less than 10 digits. The last line of input contains 0 0.

Output

For each line of input except the last you should compute and print the number of carry operations that would result from adding the two numbers, in the format shown below.

Sample Input



123 456

555 555

123 594

0 0

Sample Output



No carry operation.

3 carry operations.

1 carry operation.

题目没什么难度,唯一值得我写的就是:假如我的同桌是小明,他的作文里有10处错误。

(单复数,woc)。233333333333333333333333

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<memory.h>
#include<math.h>
using namespace std;
int a[12],b[12];
int main()
{
int x,y;
while(cin>>x>>y)
{
if(x==0&&y==0) return 0;
for(int i=1;i<12;i++) a[i]=b[i]=0;
int L1=0,L2=0,ans=0;
while(x!=0){
a[++L1]=x%10;
x/=10;
}
while(y!=0){
b[++L2]=y%10;
y/=10;
}
for(int i=1;i<=10;i++)
{
a[i]=a[i]+b[i];
if(a[i]>=10) ans++;
a[i+1]+=a[i]/10;
}
if(ans==0) printf("No carry operation.\n");
else if(ans==1) printf("1 carry operation.\n",ans);
else printf("%d carry operations.\n",ans);
}
}

zoj 1874 水题,输出格式大坑的更多相关文章

  1. 水题 ZOJ 3875 Lunch Time

    题目传送门 /* 水题:找排序找中间的价格,若有两个,选价格大的: 写的是有点搓:) */ #include <cstdio> #include <iostream> #inc ...

  2. 水题 ZOJ 3876 May Day Holiday

    题目传送门 /* 水题:已知1928年1月1日是星期日,若是闰年加1,总天数对7取余判断就好了: */ #include <cstdio> #include <iostream> ...

  3. 水题 ZOJ 3880 Demacia of the Ancients

    题目传送门 /* 水题:) */ #include <cstdio> #include <iostream> #include <algorithm> #inclu ...

  4. ZOJ 2679 Old Bill ||ZOJ 2952 Find All M^N Please 两题水题

    2679:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1679 2952:http://acm.zju.edu.cn/onli ...

  5. 水题 ZOJ 3869 Ace of Aces

    题目传送门 水题,找出出现次数最多的数字,若多个输出Nobody //#include <bits/stdc++.h> //using namespace std; #include &l ...

  6. ZOJ 17届校赛 Knuth-Morris-Pratt Algorithm( 水题)

    In computer science, the Knuth-Morris-Pratt string searching algorithm (or KMP algorithm) searches f ...

  7. ZOJ 3778 C - Talented Chef 水题

    LINK:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3778 题意:有n道菜,每道菜需要\(a_i\)道工序,有m个锅可 ...

  8. 蓝桥杯 算法训练 Torry的困惑(基本型)(水题,筛法求素数)

    算法训练 Torry的困惑(基本型) 时间限制:1.0s   内存限制:512.0MB      问题描述 Torry从小喜爱数学.一天,老师告诉他,像2.3.5.7……这样的数叫做质数.Torry突 ...

  9. CCF 201612-1 最大波动 (水题)

    问题描述 小明正在利用股票的波动程度来研究股票.小明拿到了一只股票每天收盘时的价格,他想知道,这只股票连续几天的最大波动值是多少,即在这几天中某天收盘价格与前一天收盘价格之差的绝对值最大是多少. 输入 ...

随机推荐

  1. mybaties-plus入门

    目前正在维护的公司的一个项目是一个ssm架构的java项目,dao层的接口有大量数据库查询的方法,一个条件变化就要对应一个方法,再加上一些通用的curd方法,对应一张表的dao层方法有时候多达近20个 ...

  2. 【集美大学1411_助教博客】alpha阶段后 成绩

    团队作业7 成绩(助教对团队排名) 团队名称 设想和目标 计划 资源 变更管理 设计/实现 测试/发布 团队的角色,管理,合作 总结 全组讨论的照片 团队成员在Alpha阶段的角色和具体贡献 合计 排 ...

  3. 团队作业8——Beta 阶段冲刺3rd day

    一.当天站立式会议 二.每个人的工作 (1)昨天已完成的工作(具体在表格中) 添加了订单功能,并且对订单功能进行了测试 (2)今天计划完成的工作(具体如下) 添加支付功能 (3) 工作中遇到的困难(在 ...

  4. 【Beta】Daily Scrum Meeting——Day4

    站立式会议照片 1.本次会议为第四次Meeting会议: 2.本次会议在早上9:35,在陆大2楼机房召开,本次会议为25分钟讨论今天要完成的任务以及接下来的任务安排. 燃尽图 每个人的工作分配 成 员 ...

  5. 201521123069 《Java程序设计》 第7周学习总结

    1. 本周学习总结 以你喜欢的方式(思维导图或其他)归纳总结集合相关内容. 参考资料: XMind List列表:元素以线性方式存放,允许有重复的对象. Set集:集合中的对象不按特定的方式排序,并且 ...

  6. 201521123068《Java程序设计》第4周学习总结

    1. 本周学习总结 1.1 尝试使用思维导图总结有关继承的知识点. 点击查看->高清脑图 1.2 使用常规方法总结其他上课内容. 答:学习继承与多态的知识,了解它们之间的关系:super.ext ...

  7. 201521123112《Java程序设计》第1周学习总结

    1.本周学习总结 本周通过面授课和上机课,以及在课后通过对<Java学习笔记>前一二章的阅读,初步了解了Java在计算机领域中的重要性,以及Java为什么能够这么广泛的运用在编程中.通过上 ...

  8. 201521123087《java程序设计》第13周学习总结

    1. 本周学习总结 2. 书面作业 1. 网络基础 1.1 比较ping www.baidu.com与ping cec.jmu.edu.cn,分析返回结果有何不同?为什么会有这样的不同? 答: 往返行 ...

  9. MyEclipse中Source Folder,package,folder的区别

    1.在eclipse下,package, source folder, folder都是文件夹. 但它们有区别如: 2. package:当你在建立一个package时,它自动建立到source fo ...

  10. [python学习笔记] 开篇

    今天开始学习markdown,立贴为证. 平均一天一小时.两个月先学完基础. 所有的帖子只为了学习记录,有不对的请提出,轻吐槽