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[9];
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button5_Click(object sender, EventArgs e)
{
int temp;
int rdno;
arry[0] = 0;
arry[1] = 1;
arry[2] = 2;
arry[3] = 3;
arry[4] = 4;
arry[5] = 5;
arry[6] = 6;
arry[7] = 7;
arry[8] = 8;
Random rd = new Random();
button5.Text = Convert.ToString(rd.Next(0, 9));
rdno = rd.Next(0, 9);
rdno = rd.Next(0, 9);
button5.Text = Convert.ToString(rd.Next(0, 9));
temp = arry[rdno];
arry[rdno] = arry[arry.Length - 1];
arry[arry.Length - 1] = temp;
rdno = rd.Next(0, 9);
button5.Text = Convert.ToString(rd.Next(0, 9));
temp = arry[rdno];
arry[rdno] = arry[arry.Length - 2];
arry[arry.Length - 2] = temp;
rdno = rd.Next(0, 9);
button5.Text = Convert.ToString(rd.Next(0, 9));
temp = arry[rdno];
arry[rdno] = arry[arry.Length - 3];
arry[arry.Length - 3] = temp;
rdno = rd.Next(0, 9);
button5.Text = Convert.ToString(rd.Next(0, 9));
temp = arry[rdno];
arry[rdno] = arry[arry.Length - 4];
arry[arry.Length - 4] = temp;
rdno = rd.Next(0, 9);
button5.Text = Convert.ToString(rd.Next(0, 9));
temp = arry[rdno];
arry[rdno] = arry[arry.Length - 5];
arry[arry.Length - 5] = temp;
rdno = rd.Next(0, 9);
button5.Text = Convert.ToString(rd.Next(0, 9));
temp = arry[rdno];
arry[rdno] = arry[arry.Length - 6];
arry[arry.Length - 6] = temp;
rdno = rd.Next(0, 9);
button5.Text = Convert.ToString(rd.Next(0, 9));
temp = arry[rdno];
arry[rdno] = arry[arry.Length - 7];
arry[arry.Length - 7] = temp;
rdno = rd.Next(0, 9);
button5.Text = Convert.ToString(rd.Next(0, 9));
temp = arry[rdno];
arry[rdno] = arry[arry.Length - 8];
arry[arry.Length - 8] = temp;
//output
button5.Text = Convert.ToString(rd.Next(0, 9));
button1.Text = Convert.ToString(arry[0]);
button2.Text = Convert.ToString(arry[1]);
button3.Text = Convert.ToString(arry[2]);
button4.Text = Convert.ToString(arry[3]);
button6.Text = Convert.ToString(arry[4]);
button7.Text = Convert.ToString(arry[5]);
button8.Text = Convert.ToString(arry[6]);
button9.Text = Convert.ToString(arry[7]);
button10.Text = Convert.ToString(arry[8]);
}
}
}
沒有留言:
張貼留言