本人新手,实在不知道哪里出问题了啊,
using System;using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace 实验7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string[] sources = textBox1.Text.Split(',');
int[] a = new int[sources.Length];
try
{
for (int i = 0; i < sources.Length; i++)
{
a = Convert.ToInt32(sources);
}
}
catch (Exception ex)
{
label2.Text = ex.Message;
}
for (int i = 1; i < a.Length; i++)
{
for (int j = i; j <= a.Length - 1; j++)
{
if (a[j - 1] > a[j])
{
int t = a[j - 1]; a[j - 1] = a[j]; a[j] = t;
}
}
}
label2.Text = "排序后的序列是:";
foreach (int t in a)
{
label2.Text += String.Format("{0,-4:D}", t);
}
}
}
}
输入23,12,32,36,41,62,18,38,26,22后的输出结果为:12,23,32,18,22,26,36,38,41,62。求大神告知,哪里出错了啊,另外还有,要是把数组a加入到监视窗口怎么添加啊,我是这样弄的:选中a然后右键选择监视,但是监视窗口提示错误:上下文中不存在a。怎么办啊,在线等大神。