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
- 1186 -- 小学生算术
- 小学生算术
- 小学生算术
- 小学生算术
- 小学生算术
- 小学生算术
- 小学生算术
- 小学生算术
- 小学生算术
- 小学生算术
- 小学生算术
- 小学生算术
- 小学生算术
- 小学生算术
- 小学生算术
- 小学生算术
- 小学生算术
- 小学生算术
- YUM
- mysql性能优化-慢查询分析、优化索引和配置
- 计算机编程书单
- 1185 -- 6174问题
- 【翻译自mos文章】在windows上sqlplus / as sysdba 挂起
- 1186 -- 小学生算术
- Unity3D自己常用代码
- C语言(10)--逻辑短路问题、显示安装进度、Bessel函数、消除多余的空格
- PHP 无限递归函数
- [leetcode-99]Recover Binary Search Tree(java)
- epoll实现:回调、红黑树及file中万能的private_data http://blog.csdn.net/ywh147/article/details/8684486
- BASIC CMD
- CocoaPods(2)——修复CocoaPods更新错误
- 1013. Battle Over Cities (25) (并查集)