想请问高手,怎样才能实现输入五个数,例如:1,5,3,2,4  然后通过调用已创建的函数输出有序的:1,2,3,4,5  
在主函数或者创建函数均可...谢谢啦

解决方案 »

  1.   

    用数组排序
                ArrayList al = new ArrayList();
                al.AddRange(new int[] { 1, 5, 3, 2, 4 });
                al.Sort();
                foreach (object o in al)
                {
                   //输出
                }
      

  2.   

    using System;
    using System.Collections.Generic;
    using System.Text;namespace ConsoleApplication2
    {
        class Program
        {
            static void Main(string[] args)
            {
                int[] Marks = {70, 75, 84, 53, 46, 90, 25 };
                int I = Marks.Length;            Console.Write("初始排序为:70, 75, 84, 53, 46, 90, 25");
                System.Threading.Thread.Sleep(2000);            Array.Sort(Marks);
                Console.WriteLine("");
                Console.WriteLine("按照从小到大的顺序排序后为:");
                System.Threading.Thread.Sleep(2000);            for (int x = 0; x < I; x++)
                {
                    Console.WriteLine(Marks[x]);
                    System.Threading.Thread.Sleep(1000);  
                }
                Console.Read();
            }
        }
    }