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 game_00
{
public partial class Form1 : Form
{
//宣告變數(基本類型)
//x,y變數的名稱
private int x;
private int y;
private int x2;
private int y2;
//method,方法
//Form1,名稱
public Form1()
{
InitializeComponent();
x = 100;//設定x的值
y = 100;
x2= 200;//設定y的值
y2= 200;
timer1.Interval = 1000 / 30;//1/30秒
timer1.Start();
}
//method,方法
//onpaint,名稱
private void onpaint(object sender,
PaintEventArgs e)
{
//PaintEventArgs e是一個類別 繪圖參數
//e是類別的實體(物件)
//.取出物件的資料
//.呼叫物件的功能
//e.Graphics
//取出e這個物件的Graphics這個附屬物件
//Graphics是一個物件,提供繪圖功能的物件
//其中一個功能(方法)叫做DrawEllipse
//劃出遊戲畫面
e.Graphics.DrawEllipse(Pens.Black,
x,y, 50,20);
e.Graphics.DrawEllipse(Pens.Red,
x2,y2,50, 20);
}
//定時呼叫onTimer
private void onTimer(object sender, EventArgs e)
{
// x++;
Invalidate();
}
//按下某個按鍵的時候,會呼叫這個方法
private void onKeyPress(object sender, KeyPressEventArgs e)
{
//event事件
//args參數
//KeyPressEventArgs e
//e.KeyChar 按鍵編號
if (e.KeyChar == 100)
x++;
if (e.KeyChar == 97)
x--;
if (e.KeyChar == 119)
y--;
if (e.KeyChar == 115)
y++;
}
}
}
//form1設定起始座標
//ontimer修改座標
//onpaint畫畫面
//一秒鐘做三十次)
2015年12月9日 星期三
2015年11月5日 星期四
calculator
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
{
double ans;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
double n1 = Double.Parse(textBox1.Text);
double n2 = Double.Parse(textBox2.Text);
ans = n1 + n2;
label2.Text = ans.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
double n1 = Double.Parse(textBox1.Text);
double n2 = Double.Parse(textBox2.Text);
label1.Text = "= " + (n1 - n2).ToString();
}
private void button3_Click(object sender, EventArgs e)
{
double n1 = Double.Parse(textBox1.Text);
double n2 = Double.Parse(textBox2.Text);
label1.Text = "= " + (n1 * n2).ToString();
}
private void button4_Click(object sender, EventArgs e)
{
double n1 = Double.Parse(textBox1.Text);
double n2 = Double.Parse(textBox2.Text);
if (n2 == 0)
{
MessageBox.Show("除數不能為0");
label1.Text = "= ";
return;
}
label1.Text = "= " + (n1 / n2).ToString();
}
private void textBox1_TextChanged(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 WindowsFormsApplication2
{
public partial class Form1 : Form
{
double ans;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
double n1 = Double.Parse(textBox1.Text);
double n2 = Double.Parse(textBox2.Text);
ans = n1 + n2;
label2.Text = ans.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
double n1 = Double.Parse(textBox1.Text);
double n2 = Double.Parse(textBox2.Text);
label1.Text = "= " + (n1 - n2).ToString();
}
private void button3_Click(object sender, EventArgs e)
{
double n1 = Double.Parse(textBox1.Text);
double n2 = Double.Parse(textBox2.Text);
label1.Text = "= " + (n1 * n2).ToString();
}
private void button4_Click(object sender, EventArgs e)
{
double n1 = Double.Parse(textBox1.Text);
double n2 = Double.Parse(textBox2.Text);
if (n2 == 0)
{
MessageBox.Show("除數不能為0");
label1.Text = "= ";
return;
}
label1.Text = "= " + (n1 / n2).ToString();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
2015年11月2日 星期一
拉霸卡住版
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 WindowsFormsApplication6
{
public partial class Form1 : Form
{
int i,j,p1 = -70, p2 = 70, p3 = 210, max =280, min = -140,v1 = 35,v2=30,v3=30,x1=0,x2=300,x3=600,qq=0,pp,vv=0,gg=0,wp;
int[,] ea = new int[3, 3] { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }};
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
qq++;
pp = qq % 2;
if (pp == 1)
{
timer1.Enabled = true;
/* timer2.Enabled = true;
timer3.Enabled = true;*/
}
else if(pp==0)
{
vv +=1;
/*timer2.Enabled = false;
timer3.Enabled = false;*/
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (vv ==1)
{
gg++;
wp = gg % 10;
if (wp == 0) v1 -= 5;
}
if (min - p1<= ea[0,0] && ea[0,0] < max-p1) ea[0,0]+=v1;
else ea[0,0] = min - p1;
pictureBox1.Location = new Point(x1,p1+ea[0,0]);
if (min - p2 <= ea[0,1] && ea[0,1] < max-p2) ea[0,1]+=v1;
else ea[0,1] = min - p2;
pictureBox2.Location = new Point(x1, p2+ea[0,1]);
if (min - p3 <= ea[0,2] && ea[0,2] < max - p3) ea[0,2] += v1;
else ea[0,2] = min - p3;
pictureBox3.Location = new Point(x1, p3+ea[0,2]);
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void timer2_Tick(object sender, EventArgs e)
{
if (min - p1 <= ea[1,0] && ea[1,0] <= max - p1) ea[1,0] += v2;
else ea[1,0] = min - p1;
pictureBox4.Location = new Point(x2, p1 + ea[1,0]);
if (min - p2 <= ea[1,1] && ea[1,1] <= max - p2) ea[1,1] += v2;
else ea[1,1] = min - p2;
pictureBox5.Location = new Point(x2, p2 + ea[1,1]);
if (min - p3 <= ea[1,2] && ea[1,2] <= max - p3) ea[1,2] += v2;
else ea[1,2] = min - p3;
pictureBox6.Location = new Point(x2, p3 + ea[1,2]);
}
private void pictureBox2_Click(object sender, EventArgs e)
{
}
private void timer3_Tick(object sender, EventArgs e)
{
if (min - p1 <= ea[2, 0] && ea[2, 0] <= max - p1) ea[2, 0] += v3;
else ea[2, 0] = min - p1;
pictureBox7.Location = new Point(x3, p1 + ea[2, 0]);
if (min - p2 <= ea[2, 1] && ea[2, 1] <= max - p2) ea[2, 1] += v3;
else ea[2, 1] = min - p2;
pictureBox8.Location = new Point(x3, p2 + ea[2, 1]);
if (min - p3 <= ea[2, 2] && ea[2, 2] <= max - p3) ea[2, 2] += v3;
else ea[2, 2] = min - p3;
pictureBox9.Location = new Point(x3, p3 + ea[2, 2]);
}
}
}
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 WindowsFormsApplication6
{
public partial class Form1 : Form
{
int i,j,p1 = -70, p2 = 70, p3 = 210, max =280, min = -140,v1 = 35,v2=30,v3=30,x1=0,x2=300,x3=600,qq=0,pp,vv=0,gg=0,wp;
int[,] ea = new int[3, 3] { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }};
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
qq++;
pp = qq % 2;
if (pp == 1)
{
timer1.Enabled = true;
/* timer2.Enabled = true;
timer3.Enabled = true;*/
}
else if(pp==0)
{
vv +=1;
/*timer2.Enabled = false;
timer3.Enabled = false;*/
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (vv ==1)
{
gg++;
wp = gg % 10;
if (wp == 0) v1 -= 5;
}
if (min - p1<= ea[0,0] && ea[0,0] < max-p1) ea[0,0]+=v1;
else ea[0,0] = min - p1;
pictureBox1.Location = new Point(x1,p1+ea[0,0]);
if (min - p2 <= ea[0,1] && ea[0,1] < max-p2) ea[0,1]+=v1;
else ea[0,1] = min - p2;
pictureBox2.Location = new Point(x1, p2+ea[0,1]);
if (min - p3 <= ea[0,2] && ea[0,2] < max - p3) ea[0,2] += v1;
else ea[0,2] = min - p3;
pictureBox3.Location = new Point(x1, p3+ea[0,2]);
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void timer2_Tick(object sender, EventArgs e)
{
if (min - p1 <= ea[1,0] && ea[1,0] <= max - p1) ea[1,0] += v2;
else ea[1,0] = min - p1;
pictureBox4.Location = new Point(x2, p1 + ea[1,0]);
if (min - p2 <= ea[1,1] && ea[1,1] <= max - p2) ea[1,1] += v2;
else ea[1,1] = min - p2;
pictureBox5.Location = new Point(x2, p2 + ea[1,1]);
if (min - p3 <= ea[1,2] && ea[1,2] <= max - p3) ea[1,2] += v2;
else ea[1,2] = min - p3;
pictureBox6.Location = new Point(x2, p3 + ea[1,2]);
}
private void pictureBox2_Click(object sender, EventArgs e)
{
}
private void timer3_Tick(object sender, EventArgs e)
{
if (min - p1 <= ea[2, 0] && ea[2, 0] <= max - p1) ea[2, 0] += v3;
else ea[2, 0] = min - p1;
pictureBox7.Location = new Point(x3, p1 + ea[2, 0]);
if (min - p2 <= ea[2, 1] && ea[2, 1] <= max - p2) ea[2, 1] += v3;
else ea[2, 1] = min - p2;
pictureBox8.Location = new Point(x3, p2 + ea[2, 1]);
if (min - p3 <= ea[2, 2] && ea[2, 2] <= max - p3) ea[2, 2] += v3;
else ea[2, 2] = min - p3;
pictureBox9.Location = new Point(x3, p3 + ea[2, 2]);
}
}
}
2015年10月30日 星期五
圖片拉霸未完成。
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 WindowsFormsApplication6
{
public partial class Form1 : Form
{
int i,j,p1 = -70, p2 = 70, p3 = 210, max =280, min = -140,v1=30,v2=30,v3=30,x1=0,x2=300,x3=600,qq=0,pp;
int[,] ea = new int[3, 3] { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }};
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
qq++;
pp = qq % 2;
if (pp == 1)
{
timer1.Enabled = true;
timer2.Enabled = true;
timer3.Enabled = true;
}
else if(pp==0)
{
timer1.Enabled = false;
timer2.Enabled = false;
timer3.Enabled = false;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (min - p1<= ea[0,0] && ea[0,0] <= max-p1) ea[0,0]+=v1;
else ea[0,0] = min - p1;
pictureBox1.Location = new Point(x1,p1+ea[0,0]);
if (min - p2 <= ea[0,1] && ea[0,1] <= max-p2) ea[0,1]+=v1;
else ea[0,1] = min - p2;
pictureBox2.Location = new Point(x1, p2+ea[0,1]);
if (min - p3 <= ea[0,2] && ea[0,2] <= max - p3) ea[0,2] += v1;
else ea[0,2] = min - p3;
pictureBox3.Location = new Point(x1, p3+ea[0,2]);
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void timer2_Tick(object sender, EventArgs e)
{
if (min - p1 <= ea[1,0] && ea[1,0] <= max - p1) ea[1,0] += v2;
else ea[1,0] = min - p1;
pictureBox4.Location = new Point(x2, p1 + ea[1,0]);
if (min - p2 <= ea[1,1] && ea[1,1] <= max - p2) ea[1,1] += v2;
else ea[1,1] = min - p2;
pictureBox5.Location = new Point(x2, p2 + ea[1,1]);
if (min - p3 <= ea[1,2] && ea[1,2] <= max - p3) ea[1,2] += v2;
else ea[1,2] = min - p3;
pictureBox6.Location = new Point(x2, p3 + ea[1,2]);
}
private void pictureBox2_Click(object sender, EventArgs e)
{
}
private void timer3_Tick(object sender, EventArgs e)
{
if (min - p1 <= ea[2, 0] && ea[2, 0] <= max - p1) ea[2, 0] += v3;
else ea[2, 0] = min - p1;
pictureBox7.Location = new Point(x3, p1 + ea[2, 0]);
if (min - p2 <= ea[2, 1] && ea[2, 1] <= max - p2) ea[2, 1] += v3;
else ea[2, 1] = min - p2;
pictureBox8.Location = new Point(x3, p2 + ea[2, 1]);
if (min - p3 <= ea[2, 2] && ea[2, 2] <= max - p3) ea[2, 2] += v3;
else ea[2, 2] = min - p3;
pictureBox9.Location = new Point(x3, p3 + ea[2, 2]);
}
}
}
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 WindowsFormsApplication6
{
public partial class Form1 : Form
{
int i,j,p1 = -70, p2 = 70, p3 = 210, max =280, min = -140,v1=30,v2=30,v3=30,x1=0,x2=300,x3=600,qq=0,pp;
int[,] ea = new int[3, 3] { { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 }};
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
qq++;
pp = qq % 2;
if (pp == 1)
{
timer1.Enabled = true;
timer2.Enabled = true;
timer3.Enabled = true;
}
else if(pp==0)
{
timer1.Enabled = false;
timer2.Enabled = false;
timer3.Enabled = false;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
if (min - p1<= ea[0,0] && ea[0,0] <= max-p1) ea[0,0]+=v1;
else ea[0,0] = min - p1;
pictureBox1.Location = new Point(x1,p1+ea[0,0]);
if (min - p2 <= ea[0,1] && ea[0,1] <= max-p2) ea[0,1]+=v1;
else ea[0,1] = min - p2;
pictureBox2.Location = new Point(x1, p2+ea[0,1]);
if (min - p3 <= ea[0,2] && ea[0,2] <= max - p3) ea[0,2] += v1;
else ea[0,2] = min - p3;
pictureBox3.Location = new Point(x1, p3+ea[0,2]);
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void timer2_Tick(object sender, EventArgs e)
{
if (min - p1 <= ea[1,0] && ea[1,0] <= max - p1) ea[1,0] += v2;
else ea[1,0] = min - p1;
pictureBox4.Location = new Point(x2, p1 + ea[1,0]);
if (min - p2 <= ea[1,1] && ea[1,1] <= max - p2) ea[1,1] += v2;
else ea[1,1] = min - p2;
pictureBox5.Location = new Point(x2, p2 + ea[1,1]);
if (min - p3 <= ea[1,2] && ea[1,2] <= max - p3) ea[1,2] += v2;
else ea[1,2] = min - p3;
pictureBox6.Location = new Point(x2, p3 + ea[1,2]);
}
private void pictureBox2_Click(object sender, EventArgs e)
{
}
private void timer3_Tick(object sender, EventArgs e)
{
if (min - p1 <= ea[2, 0] && ea[2, 0] <= max - p1) ea[2, 0] += v3;
else ea[2, 0] = min - p1;
pictureBox7.Location = new Point(x3, p1 + ea[2, 0]);
if (min - p2 <= ea[2, 1] && ea[2, 1] <= max - p2) ea[2, 1] += v3;
else ea[2, 1] = min - p2;
pictureBox8.Location = new Point(x3, p2 + ea[2, 1]);
if (min - p3 <= ea[2, 2] && ea[2, 2] <= max - p3) ea[2, 2] += v3;
else ea[2, 2] = min - p3;
pictureBox9.Location = new Point(x3, p3 + ea[2, 2]);
}
}
}
隨機變數nxn
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 ggwp
{
public partial class Form1 : Form
{
const int n = 4,s=300;
Button[,] buttons = new Button[n, n];
int i, j,d;
int width = s/n, height = s/n;
int[,] matrix = new int[1, n*n];
Random rnd = new Random();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
buttons[i, j] = new Button();
buttons[i, j].Location = new Point((i + 1) * s/n, (j + 1) * s/n);
buttons[i, j].Size = new Size(width, height);
buttons[i, j].Text = (i * n + j+1).ToString();
this.Controls.Add(buttons[i, j]);
}
}
}
private void pictureBox1_Click(object sender, EventArgs e)
{
for (i = 0; i < n * n; i++)
{
matrix[0, i] = i+1;
}
for (i = 0; i < n * n; i++)
{
int a = rnd.Next(1, n * n);
int b = rnd.Next(1, n * n);
int temp;
temp = matrix[0, a];
matrix[0, a] = matrix[0, b];
matrix[0, b] = temp;
}
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
buttons[i, j].Text = matrix[0, i * n + j].ToString();
}
}
}
}
}
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 ggwp
{
public partial class Form1 : Form
{
const int n = 4,s=300;
Button[,] buttons = new Button[n, n];
int i, j,d;
int width = s/n, height = s/n;
int[,] matrix = new int[1, n*n];
Random rnd = new Random();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
buttons[i, j] = new Button();
buttons[i, j].Location = new Point((i + 1) * s/n, (j + 1) * s/n);
buttons[i, j].Size = new Size(width, height);
buttons[i, j].Text = (i * n + j+1).ToString();
this.Controls.Add(buttons[i, j]);
}
}
}
private void pictureBox1_Click(object sender, EventArgs e)
{
for (i = 0; i < n * n; i++)
{
matrix[0, i] = i+1;
}
for (i = 0; i < n * n; i++)
{
int a = rnd.Next(1, n * n);
int b = rnd.Next(1, n * n);
int temp;
temp = matrix[0, a];
matrix[0, a] = matrix[0, b];
matrix[0, b] = temp;
}
for (i = 0; i < n; i++)
{
for (j = 0; j < n; j++)
{
buttons[i, j].Text = matrix[0, i * n + j].ToString();
}
}
}
}
}
2015年10月26日 星期一
數字拉霸
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 WindowsFormsApplication4
{
public partial class Form1 : Form
{
int c = 0, d=1,f,qq =0,qaq=0;
public Form1()
{
InitializeComponent();
}
private void timer2_Tick(object sender, EventArgs e)
{
if (qaq == 0)
{
qq = 0;
button10.Text = "按我開死";
button11.Text = "勝負";
}
}
private void button10_Click(object sender, EventArgs e)
{
qaq = 1;
d++;
f = d % 2;
if (f == 0&& qq==0)
{
timer1.Enabled = true;
button10.Text = "stop me";
}
else if (f ==1&qq== 0)
{
timer1.Enabled = false;
button10.Text = "繼續開死";
button11.Text = "勝負";
}
if (qq==3)
{
timer1.Enabled = true;
// qaq = 0;//
}
}
private void timer1_Tick(object sender, EventArgs e)
{
Random rnd = new Random();
int s = rnd.Next(1, 11);
int t = rnd.Next(1,11);
int u = rnd.Next(1, 11);
if (qq == 0)
{
button1.Text = s.ToString();
button4.Text = t.ToString();
button7.Text = u.ToString();
}
qq = qq + 1;
if (qq == 1)
{
s = s - 1;
t = t - 1;
u = u - 1;
button2.Text = s.ToString();
button5.Text = t.ToString();
button8.Text = u.ToString();
}
qq = qq + 1;
if (qq == 2)
{
s = s + 2;
t = t + 2;
u = u + 2;
button3.Text = s.ToString();
button6.Text = t.ToString();
button9.Text = u.ToString();
qq = qq - 2;
}
if (s == t && t == u)
{
button10.Text = "reset";
button11.Text = "ㄋ營ㄌ";
timer1.Enabled = false;
}
}
}
}
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 WindowsFormsApplication4
{
public partial class Form1 : Form
{
int c = 0, d=1,f,qq =0,qaq=0;
public Form1()
{
InitializeComponent();
}
private void timer2_Tick(object sender, EventArgs e)
{
if (qaq == 0)
{
qq = 0;
button10.Text = "按我開死";
button11.Text = "勝負";
}
}
private void button10_Click(object sender, EventArgs e)
{
qaq = 1;
d++;
f = d % 2;
if (f == 0&& qq==0)
{
timer1.Enabled = true;
button10.Text = "stop me";
}
else if (f ==1&qq== 0)
{
timer1.Enabled = false;
button10.Text = "繼續開死";
button11.Text = "勝負";
}
if (qq==3)
{
timer1.Enabled = true;
// qaq = 0;//
}
}
private void timer1_Tick(object sender, EventArgs e)
{
Random rnd = new Random();
int s = rnd.Next(1, 11);
int t = rnd.Next(1,11);
int u = rnd.Next(1, 11);
if (qq == 0)
{
button1.Text = s.ToString();
button4.Text = t.ToString();
button7.Text = u.ToString();
}
qq = qq + 1;
if (qq == 1)
{
s = s - 1;
t = t - 1;
u = u - 1;
button2.Text = s.ToString();
button5.Text = t.ToString();
button8.Text = u.ToString();
}
qq = qq + 1;
if (qq == 2)
{
s = s + 2;
t = t + 2;
u = u + 2;
button3.Text = s.ToString();
button6.Text = t.ToString();
button9.Text = u.ToString();
qq = qq - 2;
}
if (s == t && t == u)
{
button10.Text = "reset";
button11.Text = "ㄋ營ㄌ";
timer1.Enabled = false;
}
}
}
}
2015年10月23日 星期五
亂數不重複
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
{
Random rnd = new Random();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button10_Click(object sender, EventArgs e)
{
int a = rnd.Next(1, 10);
int b = rnd.Next(1, 10);
int c = rnd.Next(1, 10);
int d = rnd.Next(1, 10);
int f = rnd.Next(1, 10);
int g = rnd.Next(1, 10);
int h = rnd.Next(1, 10);
int i = rnd.Next(1, 10);
int j = rnd.Next(1, 10);
button1.Text = a.ToString();
button2.Text = b.ToString();
button3.Text = c.ToString();
button4.Text = d.ToString();
button5.Text = f.ToString();
button6.Text = g.ToString();
button7.Text = h.ToString();
button8.Text = i.ToString();
button9.Text = j.ToString();
while (button1.Text == button2.Text || button1.Text == button3.Text || button2.Text == button3.Text)
{
MessageBox.Show("他們一樣ㄌ。。。。");
button1.Text = rnd.Next(1, 10).ToString();
button2.Text = rnd.Next(1, 10).ToString();
button3.Text = rnd.Next(1, 10).ToString();
}
}
private void button1_Click(object sender, EventArgs e)
{
}
private void button3_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
{
Random rnd = new Random();
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button10_Click(object sender, EventArgs e)
{
int a = rnd.Next(1, 10);
int b = rnd.Next(1, 10);
int c = rnd.Next(1, 10);
int d = rnd.Next(1, 10);
int f = rnd.Next(1, 10);
int g = rnd.Next(1, 10);
int h = rnd.Next(1, 10);
int i = rnd.Next(1, 10);
int j = rnd.Next(1, 10);
button1.Text = a.ToString();
button2.Text = b.ToString();
button3.Text = c.ToString();
button4.Text = d.ToString();
button5.Text = f.ToString();
button6.Text = g.ToString();
button7.Text = h.ToString();
button8.Text = i.ToString();
button9.Text = j.ToString();
while (button1.Text == button2.Text || button1.Text == button3.Text || button2.Text == button3.Text)
{
MessageBox.Show("他們一樣ㄌ。。。。");
button1.Text = rnd.Next(1, 10).ToString();
button2.Text = rnd.Next(1, 10).ToString();
button3.Text = rnd.Next(1, 10).ToString();
}
}
private void button1_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
}
}
}
2015年10月2日 星期五
程式設計工藝大師
應數三甲D0250521盧宥銨
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 c=0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
c++;
button1.Text = c.ToString();
}
private void pictureBox2_Click(object sender, EventArgs e)
{
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
c++;
button1.Text = c.ToString();
button2.Text = c.ToString();
button3.Text = c.ToString();
if (c % 3 == 0)
{
button2.BackColor = System.Drawing.Color.White;
button1.BackColor = System.Drawing.Color.Red;
button3.BackColor = System.Drawing.Color.White;
}
else if (c % 3 == 1)
{
button2.BackColor = System.Drawing.Color.Yellow;
button1.BackColor = System.Drawing.Color.White;
button3.BackColor = System.Drawing.Color.White;
}
else if (c % 3 == 2)
{
button2.BackColor = System.Drawing.Color.White;
button1.BackColor = System.Drawing.Color.White;
button3.BackColor = System.Drawing.Color.Green;
}
}
private void timer2_Tick(object sender, EventArgs e)
{
}
private void button2_Click_1(object sender, EventArgs e)
{
}
}
}
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 c=0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
c++;
button1.Text = c.ToString();
}
private void pictureBox2_Click(object sender, EventArgs e)
{
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
c++;
button1.Text = c.ToString();
button2.Text = c.ToString();
button3.Text = c.ToString();
if (c % 3 == 0)
{
button2.BackColor = System.Drawing.Color.White;
button1.BackColor = System.Drawing.Color.Red;
button3.BackColor = System.Drawing.Color.White;
}
else if (c % 3 == 1)
{
button2.BackColor = System.Drawing.Color.Yellow;
button1.BackColor = System.Drawing.Color.White;
button3.BackColor = System.Drawing.Color.White;
}
else if (c % 3 == 2)
{
button2.BackColor = System.Drawing.Color.White;
button1.BackColor = System.Drawing.Color.White;
button3.BackColor = System.Drawing.Color.Green;
}
}
private void timer2_Tick(object sender, EventArgs e)
{
}
private void button2_Click_1(object sender, EventArgs e)
{
}
}
}
訂閱:
文章 (Atom)