program.cs

来自「csharp课本的源代码」· CS 代码 · 共 30 行

CS
30
字号
using System;
using System.Collections.Generic;
using System.Text;

namespace DoWhileExample
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("请输入一个正整数:");
            int x = Convert.ToInt32(Console.ReadLine());
            if (x <= 0) Console.WriteLine("不能输入0和负值!");
            else
            {
                long y = 1;
                do
                {
                    y *= x;
                    x--;
                } while (x > 0);
                Console.WriteLine("结果为{0}.", y);
            }
            //按回车键结束
            Console.ReadLine();

        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?