using
System;using
System.Collections.Generic;using
System.Linq;using
System.Text;using
System.Threading.Tasks;namespace
ConsoleApplication8{
class Program{
static void kiirtömb(int[] t){
for (int i = 0; i < t.Length; i++){
Console.Write("{0},", t[i]);}
Console.WriteLine();}
static void Main(){
int[] t = { 54, 68, 14, 70, 93, 91, 39, 37, 7, 13 }; int kezd = 0; int veg = t.Length - 1; bool csereVolt; int csere; kiirtömb(t); do{
csereVolt=false; for (int i = kezd; i <= veg - 1; i++){
if (t[i] > t[i + 1]){
csere = t[i]; t[i] = t[i + 1]; t[i + 1] = csere; csereVolt = true;}
}
veg=veg-1; if(csereVolt){
csereVolt=false; for (int i = veg; i>=kezd+1; i--){
if(t[i]<t[i-1]){
csere=t[i]; t[i]=t[i-1]; t[i-1]=csere; csereVolt=true;}
}
kezd=kezd+1;}
}
while(csereVolt); kiirtömb(t); Console.ReadKey();}
}
}