冒泡排序如何将数组从小到大排列c#

[复制链接]
查看11 | 回复5 | 2017-11-28 17:16:36 | 显示全部楼层 |阅读模式
//冒泡排序,我写了一下按升序的方法://C# Codestatic void Main(string[] args){string str = "6,9,4,10,8,2,13"; char[] q = {','}; string[] items = str.Split(q[0]); int len = items.Length; string tmp = ""; for (int i = 0; iConvert.ToInt32(ite...
回复

使用道具 举报

千问 | 2017-11-28 17:16:36 | 显示全部楼层
//需要自己输入时打开注释,清空数组//C# Codestatic void Main(string[] args)
{
int[] scores = new int[5]{23,54,13,27,55};
int i, j;// 循环变量
...
回复

使用道具 举报

千问 | 2017-11-28 17:16:36 | 显示全部楼层
bool exchange=true;for(int i=1;iarray[j+1])
...
回复

使用道具 举报

千问 | 2017-11-28 17:16:36 | 显示全部楼层
冒泡排序只需要知道,外层循环n-1次,内层循环n-i-1次...
回复

使用道具 举报

千问 | 2017-11-28 17:16:36 | 显示全部楼层
for (int i = 0; i < 数组长度; i++)
{
for (int j = 0; j < 数组长度-i-j; j++)
{
if (数组名[j]<数组名[j+1])
...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行