Hey Leute ich habe den algorythmus "SelectionSort" in der Console geschafft,
nun brauch cih in in Forms. Ich habe aber leider nicht wirklich viel erfahrung in Forms, Ich weiß das ich ne Textbox brauche für die array ausgabe und nen button der dies startet.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace SelectionSort
{
class Program
{
static void Main(string[] args)
{
Console.Title = "Selection Sort";
int[] array1 = { 3, 5, 7, 9, 8, 1, 6, 4, 2, 0 };
int[] array2 = (int[])array1.Clone();
SelectionSort(array2);
for (int i = 0; i < array2.Length; i++)
{
Console.WriteLine(array2[i]);
}
}
public static void SelectionSort(int[] array)
{
int i, j;
int min, temp;
for (i = 0; i < array.Length - 1; i++)
{
min = i;
for (j = i + 1; j < array.Length; j++)
{
if (array[j] < array[min])
{
min = j;
}
}
temp = array[i];
array[i] = array[min];
array[min] = temp;
}
}
}
}