C# 小学生算数

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();
        }
    }

 

 

 

 

 

 

 

 

 

 

 

posted on 2014-02-15 16:06  小马哥~程序之美  阅读(267)  评论(0编辑  收藏  举报

导航