VİZE 2 SORU
C# 20 SIRALAMA (Bubble Sort Sıralama Algoritması)
.png)
.png)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace _2_soru
{
publicpartialclassForm1 : Form
{
public Form1()
{
InitializeComponent();
}
privatevoid Form1_Load(object sender, EventArgs e)
{
}
int[] a = { 2, 5, 4, 7, -3, 67, 63 };//7sayı var
int[] b = { -2, 8, 6, 22, 32, 43, 45, 65 };//8 sayı var
int[] c = newint[15];
int x;
privatevoid button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < 7; i++)
{
c[i] = a[i];
}
for (int j = 0; j < 8; j++)
{
c[j + 7] = b[j];
}
for (int i = 0; i < c.Count(); i++)
{
for (int y = 0; y < c.Count()-1; y++)
{
if (c[y] > c[y+1])
{
x = c[y];
c[y] = c[y+1];
c[y+1] = x;
}
}
}
for (int i = 0; i < 15; i++)
{
listBox1.Items.Add(c[i]);
}
}
}
}