编写一个程序,求出1+(1+2)+(1+2+3)+…+(1+2+3+…+10)之和.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace _5a

{

    class Program

    {

        static void Main(string[] args)

        {

            int sum = 0;

            for (int i = 10; i >0; i--)//用来控制最大的那个数  

            {

                for (int j =i; j>0 ; j--)//从最大的那个数加到1的值

                {

                    sum += j;

                }

            }

            Console.WriteLine(sum);

            Console.ReadKey();

        }

    }

}

版权声明:本文为OnePiece_only原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
THE END
< <上一篇
下一篇>>