首页 > 其他 > 详细

C# 小学生算数

时间:2014-02-15 18:31:48      阅读:523      评论:0      收藏:0      [点我收藏+]

class Program
    {
        static void Main(string[] args)
        {
            int a = Int32.Parse(Console.ReadLine());//题目是小学生算数,两个数相加,求需要多少次进位,整数不超过9位
            int b = Int32.Parse(Console.ReadLine());
            int c = 0;
            int d = 0;
            for (int i = 9; i >= 0; i--)
            {
                c = (a % 10 + b % 10 + c) > 9 ? 1 : 0;
                d += c;
                a /= 10;
                b /= 10;
            }
            Console.WriteLine("{0}",d);
            Console.ReadKey();
        }
    }

C# 小学生算数

原文:http://www.cnblogs.com/HorseKing/p/3550614.html

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