I have wrote this code for c#
void SelectionSort()
{
clearFontColor();
int i, j, min, temp;
for (i = 0; i < 9; i++)
{
min = i;
for (j = i + 1; j < 10; j++)
{
if (input[min] > input[j])
{
min = j;
}
}
if (min != i)
{
temp = input[i];
input[i] = input[min];
input[min] = temp;
}
}
show(input);
}
But this is doing only one step and later it stops.How to achieve that.
The button for sort action is like
private void button2_Click(object sender, EventArgs e)
{
// lbl_step.Visible = true;
if (radioButton2.Checked)
{
InsertionSort();
}
else if (radioButton1.Checked)
{
bubble();
}
else if (radioButton3.Checked)
{
SelectionSort();
}
}
and its working for just one time after that it stops working.
Assuming your code is correct you have do something like this. So your code will run through and show the change howevever, this is happening so faster you won’t see it on the GUI. You need to make variables i a class member. Then in your button click, you increment i.
So the summary: Set i to a number each button click. Then your method will only do one iteration and show the user interface. To continue you click the button again and increment i (make sure to check bounds).