Witam, mam pewien.. dziwny problem, oto kod:
using System;
namespace sortowaniebbb
{
class Program
{
static void zamien(ref int a, ref int b)
{
int pomoc = a;
a = b;
b = pomoc;
}
public static void sortowanie_babelkowe(ref int[] tab,int n )
{
for (int j = n - 1; j < 0; j--)
{
for (int i = 0; i < j; i++)
if (tab[i] > tab[i + 1])
zamien(ref tab[i], ref tab[i + 1]);
}
}
static void Main()
{
int[] sort = new int[9];
sort[0] = 2;
sort[1] = 3;
sort[2] = 8;
sort[3] = 4;
sort[4] = 9;
sort[5] = 0;
sort[6] = 1;
sort[7] = 5;
sort[8] = 7;
sortowanie_babelkowe(ref sort, 9);
//////////////////////////////////////////////////////////
/* int[] sort = new int[9];
sort[0] = 2;
sort[1] = 3;
sort[2] = 8;
sort[3] = 4;
sort[4] = 9;
sort[5] = 0;
sort[6] = 1;
sort[7] = 5;
sort[8] = 7;
for (int i = 0; i < 9; i++)
{
Console.WriteLine(sort[i]);
}
Array.Sort(sort);
Console.WriteLine();
for (int i = 0; i < 9; i++)
{
Console.WriteLine(sort[i]);
}*/
Console.ReadKey();
}
}
}
Mam funkcję sortującą tablicę sposobem bąbelkowym i... jak wypisać te posortowaną tablice? Próbowałem kilku rzeczy i nic... Zdesperowałem się jak widać do skorzystania z gotowca ostatecznie ale nie o to mi chodzi.