C#库:冒泡算法

        public int[] SortInt(int[] R)
        {
            for (int i = R.Length - 1; i >= 0; i--)
            {
                for (int n = 0; n < i; n++)
                {
                    if (R[n] > R[n + 1])
                    {
                        int temp;
                        temp = R[n];
                        R[n] = R[n + 1];
                        R[n + 1] = temp;
                    }
                }
            }

            return R;
        }

Leave a Reply

Your email address will not be published. Required fields are marked *