class Class1
{
public int[] a;
public Class1()
{
Random r1 = new Random();
a = new int[10];
a[0] = r1.Next(0, 100);
for (int i = 1; i < 10; i++)
{
bool chk;
do
{
a[i] = r1.Next(0, 100);
chk = false;
for (int j = 0; j < i; j++)
{
if (a[i] == a[j])
{
chk = true;
}
}
}
while (chk);
}
}
//public int[] Sort()
//{
// int[] b = new int[10];
// int min;
// for (int n = 0; n < 10; n++)
// {
// int index = 0;
// min = a[0];
// for (int i = 1; i < 10 - n; i++)
// {
// if (min > a[i])
// {
// min = a[i];
// index = i;
// }
// }
// b[n] = min;
// a[index] = a[9 - n];
// }
// return b;
//}
public void SortB()
{
int w;
for (int i = 0; i < 10; i++)
{
for (int j = i + 1; j < 10; j++)
{
if (a[i] > a[j])
{
w = a[i];
a[i] = a[j];
a[j] = w;
}
}
}
}
}
public partial class Form1 : Form
{
Class1 obj;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
obj = new Class1();
listBox1.Items.Clear();
for (int i = 0; i < 10; i++)
{
listBox1.Items.Add(obj.a[i]);
}
}
//private void button1_Click(object sender, EventArgs e)
//{
// int[] s = obj.Sort();
// for (int i = 0; i < 10; i++)
// {
// listBox2.Items.Add(s[i]);
// }
//}
private void button1_Click(object sender, EventArgs e)
{
obj.SortB();
for (int i = 0; i < 10; i++)
{
listBox2.Items.Add(obj.a[i]);
}
}
}
website中使用websevers的数据排列/Files/loverain/WebSite3.zip
经过孫さん帮忙终于实现了
头晕脑涨了,他不给俺让俺自己看,俺怎么也看不明白啊!
先留个纪念吧!
我想什么时候我要是看这个觉得简单得不行了我就厉害了
还是蓮見さん好
虽然让俺自己绞尽脑汁了一番(那滋味可真不好受,睁大眼睛就是看不明白!!!)
最后还是给俺讲了
据说刚才孫さん告诉俺的写法不对
可是为什么结果正确呢??
比刚才是明白多了
不过我怀疑让俺自己做还是做不出来/Files/loverain/WebSite3last.zip