



























今天看了一下数据结构(c),突然有一种冲动,想写一下c#的一些算法和数据结构的文章,就从今天开始吧。
今天的第一个内容是c#冒泡程序。
1
using System;
2
namespace ma
3
{
4
public class po
5
{
6
int i;
7
int temp;
8
int j;
9
public void Sort(int[] list)
10
{
11
while(j<list.Length)
12
{
13
for(i=0;i<list.Length-1;i++)
14
{
15
if(list[i]>list[i+1])
16
{
17
temp=list[i];
18
list[i]=list[i+1];
19
list[i+1]=temp;
20
}
21
}
22
j++;
23
}
24
}
25
}
26
public class mainclass
27
{
28
public static void Main()
29
{
30
int[] arry=new int[]{5,8,1,9,0,15,88};
31
po s=new po();
32
s.Sort(arry);
33
for(int m=0;m<arry.Length;m++)
34
{
35
Console.Write("{0}",arry[m]);
36
Console.Write(" ");
37
}
38
}
39
}
40
}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。