本文介绍了为数组排序算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 大家好! 我正在考虑排序算法,我为此编写了一个小算法...它可以更加精致...... Hi Guys!I was thinking for sorting algo,i have written a small algo for this...can it be more refined...int[] unSortedArray = { 9, 4, 5, 1,7, 3, 8, 2, 6 }; int j = 0; for (int i = 0; i < (unSortedArray.Length - 1) * (unSortedArray.Length - j); i++) { if (i == unSortedArray.Length - j -1) { i = 0; j++; } if (unSortedArray[i] > unSortedArray[i + 1]) { int temp = unSortedArray[i]; unSortedArray[i] = unSortedArray[i + 1]; unSortedArray[i + 1] = temp; } } 任何想法都表示赞赏!!! 问候, Vikas Any thought is appreciated!!!Regards,Vikas推荐答案 using System;class Program{ static void Main() { // Simple sort call. int[] values = {1,5,3,0,3,5,7 }; Array.Sort(values); foreach (int value in values) { Console.Write(value); Console.Write(' '); } Console.WriteLine(); }} 这篇关于为数组排序算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-23 06:12