冒泡排序

2021-07-10 00:05

阅读:404

标签:lin   adk   line   OLE   color   res   core   []   冒泡排序   

int[] scores = { 89, 90, 98, 56, 60, 91, 93, 85 };
            Console.WriteLine("排序前:");
            foreach(int score in scores)
            {
                Console.Write(score + " ");
            }
            Console.WriteLine();
            Console.ReadKey();

            int temp;
            for (int i = 0; i 1; i++) {
                for(int j = i + 1; j )
                {
                    if (scores[i]  scores[j]) {
                        temp=scores[i];
                        scores[i] = scores[j];
                        scores[j] = temp;
                    }
                }
            }
            Console.WriteLine("从大到小排序:");
            foreach (int score in scores) {
                Console.Write(score + " ");
            }
            Console.ReadKey();

 

冒泡排序

标签:lin   adk   line   OLE   color   res   core   []   冒泡排序   

原文地址:https://www.cnblogs.com/xixixing/p/9565132.html


评论


亲,登录后才可以留言!