冒泡排序
class Program
{
public static void ssort(int[] list)
{
int i, j, min, temp;
for (i = 0; i < list.Length - 1; i++)
{
min = i;
for (j = i + 1; j < list.Length; j++)
{
if (list[j] < list[min])
min = j;
}
temp = list[i];
list[i] = list[min];
list[min] = temp;
}
}
static void Main(string[] args)
{
int[] arrlist = new int[] { 49, 38, 65, 97, 76, 13, 27, 49 };
ssort(arrlist);
for (int n = 0; n < arrlist.Length; n++)
{
Console.Write("{0}",arrlist[n]+" ");
}
Console.WriteLine();
}
}
{
public static void ssort(int[] list)
{
int i, j, min, temp;
for (i = 0; i < list.Length - 1; i++)
{
min = i;
for (j = i + 1; j < list.Length; j++)
{
if (list[j] < list[min])
min = j;
}
temp = list[i];
list[i] = list[min];
list[min] = temp;
}
}
static void Main(string[] args)
{
int[] arrlist = new int[] { 49, 38, 65, 97, 76, 13, 27, 49 };
ssort(arrlist);
for (int n = 0; n < arrlist.Length; n++)
{
Console.Write("{0}",arrlist[n]+" ");
}
Console.WriteLine();
}
}