日期:2014-05-17 浏览次数:20723 次
private void butok_Click(object sender, EventArgs e)
{
string str="8 9 3 16 10 10 8 6 10 12";
string strTemp = "";
string[] Arr = arrayList(str);
for (int i = 0; i < Arr.Length; i++)
{
strTemp = strTemp + Arr[i].ToString() + " ";
}
strTemp = strTemp.Substring(0, strTemp.Length - 1);
textBox1.Text = strTemp;
}
private string[] arrayList(string strTemp)
{
string[] a = strTemp.Split(' ');
string temp;
for (int i = 0; i < a.Length; i++)
{
for (int j = i + 1; j < a.Length; j++)
{
if (Convert.ToDouble(a[i]) > Convert.ToDouble(a[j]))
{
temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
return a;
}