daponi 发表于 2016-9-28 20:34:59

C#窗口冒泡升序与降序排序

C#小白用两个文本框1和2,文本框1输入整数,点击按钮1文本框2升序输入整数,点击按钮2文本框2降序输入整数。我这样写是哪错了??
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace MaoPaoPaiXu
{
    public partial class Form1 : Form
    {
      public Form1()
      {
            InitializeComponent();
      }
      private void label1_Click(object sender, EventArgs e)
      {
      }
      private void Form1_Load(object sender, EventArgs e)
      {
      }
      private void button1_Click(object sender, EventArgs e)
      {
            textBox2.Text = "";
            String[] str = textBox1.Text.Trim().Split(' ');
            int[] a = new int;
            int temp;
            for (int i = 0; i < str.Length; i++)
            {
                a = int.Parse(str);
            }
            for (int i = 0; i < a.Length; i++) {
                for (int j = 0; j < a.Length; j++) {
                  if (a > a) {
                        temp = a;
                        a = a;
                        a = temp;
                  }
                }
                textBox2.Text += a + " ";
            }
            
      }
      private void button2_Click(object sender, EventArgs e)
      {
            textBox2.Text = "";
            String[] str = textBox1.Text.Trim().Split(' ');
            int[] a = new int;
            int temp;
            for (int i = 0; i < str.Length; i++)
            {
                a = int.Parse(str);
            }
            for (int i = 0; i < a.Length; i++)
            {
                for (int j = 0; j < a.Length; j++)
                {
                  if (a <a)
                  {
                        temp = a;
                        a = a;
                        a = temp;
                  }
                }
                textBox2.Text += a + " ";
            }
            
      }
    }
}

daponi 发表于 2016-9-28 20:36:25

刚学C#,哪位大神来指导下 ???

daponi 发表于 2016-9-28 20:46:56

大神都到哪去了???

daponi 发表于 2016-9-28 22:51:14

嗯,已经自己做好了

ibcadmin 发表于 2016-9-29 09:34:50

.................来晚一步

剑弑 发表于 2016-9-29 15:09:31

。。。。。。来晚了
页: [1]
查看完整版本: C#窗口冒泡升序与降序排序