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
{
Button[,] Buttons = new System.Windows.Forms.Button[5, 5];
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 1; i < 5; i++)
{
for (int j = 1; j < 5; j++)
{
Buttons[i, j] = new Button();
Buttons[i, j].Size = new Size(50, 50);
Buttons[i, j].Location = new Point( i * 50, j * 50);
this.Controls.Add(Buttons[ i , j]);//出現在畫面中
}
}
}
private void button1_Click(object sender, EventArgs e)
{
Random rnd = new Random();
int[] a = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
for (int i = 0; i < 16; ++i)
{
int j = rnd.Next(15);
int t = a[j];
a[j] = a[i];
a[i] = t;
}
int k = 0, c, v;
for (int m = 1; m < 5; m++)
{
for (int n = 1; n < 5; n++)
{
Buttons[m, n].Text = a[k].ToString();
k = k + 1;
}
}
for (int b = 0; b < 16; ++b)
{
if (a[b] == 0)
{
c = b % 4 + 1;
v = b / 4 + 1;
Buttons[v, c].Text = "";
}
}
}
private void button2_Click(object sender, EventArgs e)
{
int x = 0;
for (int s = 1; s < 5; s++)
{
for (int d = 1; d < 5; d++)
{
Buttons[d, s].Text = x.ToString();
x = x + 1;
}
}
}
}
}
2015年10月30日 星期五
2015年10月23日 星期五
推盤遊戲 D0250623 廖啟淵
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 r1 = 0;
int r2 = 0;
int r3 = 0;
int r4 = 0;
int r5 = 0;
int r6 = 0;
int r7 = 0;
int r8 = 0;
int r9 = 0;
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 Form1_Load(object sender, EventArgs e)
{
}
private void button7_Click(object sender, EventArgs e)
{
}
private void button6_Click(object sender, EventArgs e)
{
}
private void button5_Click(object sender, EventArgs e)
{
}
private void button4_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
}
private void button10_Click(object sender, EventArgs e)
{
Random rnd = new Random();
int[] a = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
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();
//button10.Enabled = false;
}
private void button1_Click(object sender, EventArgs e)
{
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
}
}
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 r1 = 0;
int r2 = 0;
int r3 = 0;
int r4 = 0;
int r5 = 0;
int r6 = 0;
int r7 = 0;
int r8 = 0;
int r9 = 0;
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 Form1_Load(object sender, EventArgs e)
{
}
private void button7_Click(object sender, EventArgs e)
{
}
private void button6_Click(object sender, EventArgs e)
{
}
private void button5_Click(object sender, EventArgs e)
{
}
private void button4_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
}
private void button10_Click(object sender, EventArgs e)
{
Random rnd = new Random();
int[] a = { 0, 1, 2, 3, 4, 5, 6, 7, 8 };
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();
//button10.Enabled = false;
}
private void button1_Click(object sender, EventArgs e)
{
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
}
}
2015年10月2日 星期五
程式設計工藝大師 D0250623 廖啟淵
程式設計工藝大師
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, b, c, r,t = 0;
public Form1()
{
InitializeComponent();
}
private void button2_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
t = t + 1;
r = t % 6;
b = r;
button2.Text = b.ToString();
if (b == 3)
{
button2.BackColor = System.Drawing.Color.FromName("Yellow");
}
else
{
button2.BackColor = System.Drawing.Color.FromName("White");
}
a = r;
button1.Text = a.ToString();
if (a > 3)
{
button1.BackColor = System.Drawing.Color.FromName("Red");
}
else
{
button1.BackColor = System.Drawing.Color.FromName("White");
}
c = r;
button3.Text = c.ToString();
if (c < 3)
{
button3.BackColor = System.Drawing.Color.FromName("Green");
}
else
{
button3.BackColor = System.Drawing.Color.FromName("White");
}
}
}
}
訂閱:
文章 (Atom)