2015年10月23日 星期五

推盤遊戲 D0250565 蔡坤成

程式設計工藝大師

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            button1.Enabled = false;
            button2.Enabled = false;
            button3.Enabled = false;
            button4.Enabled = false;
            button5.Enabled = false;
            button6.Enabled = false;
            button7.Enabled = false;
            button8.Enabled = false;
            button9.Enabled = false;
        }

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

        private void button10_Click(object sender, EventArgs e)
        {
            Random rnd = new Random();
            int[] a = {  1, 2, 3, 4, 5, 6, 7, 8, 9 };
            for (int i = 0; i < 9; ++i)
            {
                int j = rnd.Next(8);
                int t = a[j];
                a[j] = a[i];
                a[i] = t;
            }
            button1.Text = a[0].ToString();
            button2.Text = a[1].ToString();
            button3.Text = a[2].ToString();
            button4.Text = a[3].ToString();
            button5.Text = a[4].ToString();
            button6.Text = a[5].ToString();
            button7.Text = a[6].ToString();
            button8.Text = a[7].ToString();
            button9.Text = a[8].ToString();
        }
    }
}

沒有留言:

張貼留言