close
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 WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
       
        int a = 3, t=0;
        int[] rand = new int[16];
        Button[,] buttons = new Button[4, 4];
        Random randomc1 = new Random(Guid.NewGuid().GetHashCode());

        public Form1()
        {
            InitializeComponent();


        }

        private void Form1_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 4; ++i)
            {

                for (int j = 0; j < 4; ++j)
                {
                    buttons[i, j] = new Button();
                    buttons[i, j].Location = new Point(i * 80, j * 80);
                    buttons[i, j].Size = new Size(80, 80);

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

                }
            }
        }

        private void button10_Click(object sender, EventArgs e)
        {
            請投金幣.Enabled = true;
            拉下.Enabled = false;
            for (int i = 0; i < 16; i++)
            {

                rand[i] = randomc1.Next(1, 17);

                for (int j = 0; j < i; j++)
                {
                    while (rand[j] == rand[i])
                    {
                        j = 0;
                        rand[i] = randomc1.Next(1, 17);
                    }
                }
            }

            for (int i = 0; i < 4; ++i)
            {

                for (int j = 0; j < 4; ++j)
                {
                    buttons[i, j].Text = Convert.ToString(rand[i * 4 + j]);

                }
            }
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        private void button11_Click(object sender, EventArgs e)
        {
            請投金幣.Text = "請投金幣";
            拉下.Enabled = true;
            請投金幣.Enabled = false;
        }

        private void button1_Click(object sender, EventArgs e)
        {
                     for (int i = 0; i < 16; i++)
            {

                for (int j = 0; j < i; j++)
                {
                    if (rand[j] > rand[i])
                    {
                       
                        t = rand[i];
                        rand[i] = rand[j];
                        rand[j] = t;
                    }
                }
            }

            for (int i = 0; i < 4; ++i)
            {

                for (int j = 0; j < 4; ++j)
                {
                    buttons[i, j].Text = Convert.ToString(rand[i * 4 + j]);

                }
            }
        }
        }
    }

未命名.png 

arrow
arrow
    全站熱搜

    a29yly1111 發表在 痞客邦 留言(1) 人氣()