(1)1~100之和
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 职称枚举类型
{

    class Class1
    {




        static void Main(string[] args)
        {
            int s = 0;
            int i = 1;
            while (i <= 100) {
                s = s + i++;
            
            }
            Console.WriteLine("和是:{0}",s);
        }
    }
}

(2)10!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 职称枚举类型
{

    class Class1
    {




        static void Main(string[] args)
        {
            long t = 1;
            int i = 1;
            do
            {
                t = t * i++;

            } while (i <= 10);
            Console.WriteLine("10!={0}",t);
        }
    }
}



(3)1~100之和

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 职称枚举类型
{

    class Class1
    {




        static void Main(string[] args)
        {
            int s = 0;
            for (int i = 1; i <= 100; i++) {
                s = s + i;
            
            }
            Console.WriteLine("和是{0}",s);
        }
    }
}




本文转载:CSDN博客