using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
int[] arry=new int[10];
public Form1()
{
InitializeComponent();
for (int i = 0; i < 9; i++)
arry[i] = i + 1;
button1.Text = Convert.ToString(arry[0]);
button2.Text = Convert.ToString(arry[1]);
button3.Text = Convert.ToString(arry[2]);
button4.Text = Convert.ToString(arry[3]);
button5.Text = Convert.ToString(arry[4]);
button6.Text = Convert.ToString(arry[5]);
button7.Text = Convert.ToString(arry[6]);
button8.Text = Convert.ToString(arry[7]);
button9.Text = Convert.ToString(arry[8]);
}
private void button10_Click(object sender, EventArgs e)
{
Random rd = new Random();
int temp; int rdno;
for (int i = 0; i < 10; i++)
{
rdno = rd.Next(0, 10);
temp = arry[i];
arry[i] = arry[rdno];
arry[rdno] = temp;
}
button1.Text = Convert.ToString(arry[0]);
button2.Text = Convert.ToString(arry[1]);
button3.Text = Convert.ToString(arry[2]);
button4.Text = Convert.ToString(arry[3]);
button5.Text = Convert.ToString(arry[4]);
button6.Text = Convert.ToString(arry[5]);
button7.Text = Convert.ToString(arry[6]);
button8.Text = Convert.ToString(arry[7]);
button9.Text = Convert.ToString(arry[8]);
}
}
}
沒有留言:
張貼留言