close

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 推方塊
{

public partial class Form1 : Form
{
Button[,] buttons = new Button[4, 4];
public Form1()
{
InitializeComponent();
}

public static void Shuffle(int[] arr)
{
arr = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 0 };
Random rand = new Random();
int temp = -1;
int pos = -1;
for(int i=arr.Length-1;i>=0;i--)
{
pos = rand.Next(i);
temp = arr[pos];
arr[pos] = arr[i];
arr[i] = temp;
}

}
private void Form1_Load(object sender, EventArgs e)
{

Random rand = new Random();


for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
buttons[i, j] = new Button();
buttons[i, j].Size = new Size(80, 80);
buttons[i, j].Location = new Point(i * 85, j * 85);
buttons[i, j].Text = Convert.ToString(rand.Next(0, 15));

this.Controls.Add(buttons[i, j]);
}


}
}
}
}未命名  

arrow
arrow
    全站熱搜

    p06299995 發表在 痞客邦 留言(0) 人氣()