1186 -- 小学生算术

来源:互联网 发布:网达软件工资水平 编辑:程序博客网 时间:2024/06/11 11:55

小学生算术

Time Limit:1000MS  Memory Limit:65536K
Total Submit:67 Accepted:57

Description

很多小学生在学习加法时,发现“进位”特别容易出错。你的任务是计算两个三位数在相加时需要多少次进位。你编制的程序应当可以连续处理多组数据,直到读到两个0(这是输入结束标记)。

Input

输入两个正整数m,n.(m,n,都是三位数)

Output

输出m,n,相加时需要进位多少次。

Sample Input

123 456555 555123 5940 0

Sample Output

03 1

Source

using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace AK1186 {    class Program {        static void Main(string[] args) {            string sb;            while ((sb = Console.ReadLine()) != null) {                string[] s = sb.Split();                int m = int.Parse(s[0]), n = int.Parse(s[1]);                if (m + n == 0) break;                int a = m / 100;                int b = m / 10 % 10;                int c = m % 10;                int x = n / 100;                int y = n / 10 % 10;                int z = n % 10;                int i = 0;                if ((c + z) >= 10) { i++; b++; }                if ((b + y) >= 10) { i++; a++; }                if ((a + x) >= 10) { i++; }                Console.WriteLine(i);            }        }    }}


0 0
原创粉丝点击