using System;
using System.Windows.Forms;

namespace _7_17
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public static int[] BubbleSort(int[] a)
        {
            int n = a.Length;
            int temp = 0;
            
            for (int i = 1; i < n; i++)
                for (int j = 0; j < n - i; j++)
                    if (a[j] > a[j + 1])
                    {
                        temp = a[j];
                        a[j] = a[j + 1];
                        a[j + 1] = temp;
                    }
            
            return a;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int[] array = { 5, 9, 4, 1 };
            array = BubbleSort(array);
            
            foreach (var i in array)
                listBox1.Items.Add(i);
        }
    }
}