(1)新建Windows应用程序MyApplicaton4,添加控件。
(2)为按钮的单击事件添加代码:
private void button1_Click(object sender, EventArgs e)
{
string [] number = textBox1.Text.Split(’,’);
int[]temp = new int[number.Length];
int len=number .Length ;
//转换成数字
for (int i =0; i < len; i++)
{
temp[i] = Convert.ToInt32(number[i]);
}
int te;
//从大到小
for (int i = 0; i < len-1; i++) {
for (int j = i+1; j < len; j++) {
if (temp[j] > temp[i])
{
te = temp[j];
temp[j] = temp[i];
temp[i] = te;
}
}
textBox3.Tex
设计一个简单的windows程序,输入5个数字,然后排序并输出。
最新推荐文章于 2023-11-09 20:59:27 发布