private void button27_Click(object sender, EventArgs e)
{
int[] array = new int[] { 10, 3, 2, 4, 90, 50, 20, 34, 22, 49 };
int[] newArray = new int[array.Length];
int everyMin=0;
for (int i = 0; i < array.Length; i++)
{
array = SetMinToMax(array, out everyMin);
newArray[i] = everyMin;
}
for (int i = 0; i < newArray.Length; i++)
{
textBox1.Text = newArray[i].ToString() + "," + textBox1.Text;
}
}
private int[] SetMinToMax(int[] array,out int Min)
{
Min = 9999999;
int minIndex = -1;
for (int i = 0; i < array.Length; i++)
{
if (array[i]< Min)
{
Min = array[i];
minIndex = i;
}
}
if (minIndex!=-1)
{
array[minIndex] = 9999999;
}
return array;
}
|