public static void BubbleSort(int[] list) { for (int i = 0; i < list.Length; i++) { for (int j = i; j < list.Length; j++) { if (list[i] < list[j]) { int temp = list[i]; list[i] = list[j]; list[j] = temp; } } } } protected void Page_Load(object sender, EventArgs e) { int[] list = { 8366, 45, 123, 789 }; BubbleSort(list); for (int i = 0; i < list.Length; i++) { Response.Write(list[i].ToString()+"</br>"); } }
ArrayList list = new ArrayList (); int size = 0; do { int a = Convert.ToInt32(Console.ReadLine()); list.Add(a); size++; } while (size < 5); list.Sort(); for (int i = 0; i < list.Count; i++) { Console.WriteLine("{0} : {1}", i, list[i]); } Console.ReadLine();
Array.Sort(array);
{
for (int i = 0; i < list.Length; i++)
{
for (int j = i; j < list.Length; j++)
{
if (list[i] < list[j])
{
int temp = list[i];
list[i] = list[j];
list[j] = temp;
}
}
}
} protected void Page_Load(object sender, EventArgs e)
{
int[] list = { 8366, 45, 123, 789 };
BubbleSort(list);
for (int i = 0; i < list.Length; i++)
{
Response.Write(list[i].ToString()+"</br>");
}
}
int size = 0;
do
{
int a = Convert.ToInt32(Console.ReadLine());
list.Add(a);
size++;
}
while (size < 5);
list.Sort();
for (int i = 0; i < list.Count; i++)
{
Console.WriteLine("{0} : {1}", i, list[i]);
}
Console.ReadLine();