C#

04.C# - 알고리즘 : 최소값

Godffs 2009. 8. 5. 23:38
반응형
using System;

public class 최소값
{
    public static void Main()
    {
        //[1]Init
        int min = Int32.MaxValue;

        //[2] Input
        int[] data = { -2, -5, -3, -7, -1 };
       
        //[3] Process : MAX
        for (int i = 0; i < data.Length; i++)
        {
            if (min > data[i])
            {
                min = data[i];
            }
        }

        //[4] Output       
        Console.WriteLine("최소값 : {0}", min);

        //[5] Dispose
        min = 0;
    }
}


▼ 정수형중 가장 큰 값으로 초기화 했습니다. 참고강좌(19장-최대값)

반응형