天天看點

C#循環輸入數字并找出最大值

using System;
using System.Collections.Generic;
using System.Text;

namespace KnowledgePoint
{
    class _15_Ex_DoWhile
    {
        static void Main(string[] args)
        {
            int input = 0, maxValue = 0, i = 1;
            do
            {
                Console.Write("請輸入第{0}個數(輸入0結束):", i);
                input = Convert.ToInt32(Console.ReadLine());
                if (maxValue < input)
                {
                    maxValue = input;
                }
                i++;
            } while (input != 0);
            Console.WriteLine("最大值:" + maxValue);

            Console.ReadKey();
        }
    }
}