30
1
using System;
2
3
public class Program
4
{
5
public static void Main()
6
{
7
int[] a = {4, 5, 11, 13, 17, 21, 17};
8
int iteraciones = 0;
9
//Burbuja
10
for(int x = 1; x < a.Length; x++)
11
{
12
for(int y = 0; y < a.Length - 1; y++)
13
{
14
if(a[x] < a[y])
15
{
16
int tmp = a[y];
17
a[y] = a[x];
18
a[x] = tmp;
19
}
20
iteraciones++;
21
}
22
}
23
24
foreach(var item in a)
25
{
26
Console.WriteLine(item);
27
}
28
Console.WriteLine("<" + iteraciones + ">");
29
}
30
}
Cached Result