arrayi hem sort methodu hem de modul kullanarak dizilmektedir using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System********s.Forms;
namespace sortarray
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int[] arr = { 12, 54, 1, 0, 89, 45, 78, 32, 64, -45, -20, 14, 75, 96 };
label1.Text = "Original Values in Order:\n";
for (int i = 0; i < arr.Length; i++)
label1.Text += " "+arr[i];
Array.Sort(arr);
label1.Text += " \nWithout Models:\n";
for (int i = 0; i < arr.Length; i++)
label1.Text += " " + arr[i];
Array.Reverse(arr);
label1.Text += "\n\n";
for (int i = 0; i < arr.Length; i++)
label1.Text += " " + arr[i];
Bublesort(arr);
label1.Text += "\nAfter Sorted With Model:\n";
for (int i = 0; i < arr.Length; i++)
label1.Text += " " + arr[i];
}
void Bublesort(int[] a)
{
for (int i = 1; i < a.Length; i++)
{
for (int j = 0; j < a.Length - 1; j++)
if (a[j] > a[j+1])
Sort(a, j);
}
}
void Sort(int[] c, int first)
{
int temp;
temp = c[first];
c[first] = c[first + 1];
c[first + 1] = temp;
}
}
}
sorting array
sorting array
Konuyu Okuyanlar: 1 Ziyaretçi