九宮格點擊顯示圈叉連線即可獲勝
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 WindowsFormsApplication5
{
public partial class Form1 : Form
{
int c;
public Form1()
{
InitializeComponent();
}
{
public partial class Form1 : Form
{
int c;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
button1.Text = "";
button2.Text = "";
button3.Text = "";
button4.Text = "";
button5.Text = "";
button6.Text = "";
button7.Text = "";
button8.Text = "";
button9.Text = "";
}
{
button1.Text = "";
button2.Text = "";
button3.Text = "";
button4.Text = "";
button5.Text = "";
button6.Text = "";
button7.Text = "";
button8.Text = "";
button9.Text = "";
}
private void button1_Click(object sender, EventArgs e)
{
int r;
c = c + 1;
r = c % 2;
label1.Text = Convert.ToString(r);
if (r == 1)
button1.Text = "O";
else if (r == 0)
button1.Text = "X";
button1.Enabled = false;
if (button1.Text == button2.Text & button2.Text == button3.Text & button1.Text == button3.Text)
MessageBox.Show("P1 WIN!");
}
{
int r;
c = c + 1;
r = c % 2;
label1.Text = Convert.ToString(r);
if (r == 1)
button1.Text = "O";
else if (r == 0)
button1.Text = "X";
button1.Enabled = false;
if (button1.Text == button2.Text & button2.Text == button3.Text & button1.Text == button3.Text)
MessageBox.Show("P1 WIN!");
}
private void button2_Click(object sender, EventArgs e)
{
int r;
c = c + 1;
r = c % 2;
label1.Text = Convert.ToString(r);
if (r == 1)
button2.Text = "O";
else if (r == 0)
button2.Text = "X";
button2.Enabled = false;
if (button1.Text == button2.Text & button2.Text == button3.Text & button1.Text == button3.Text)
MessageBox.Show("P1 WIN!");
}
{
int r;
c = c + 1;
r = c % 2;
label1.Text = Convert.ToString(r);
if (r == 1)
button2.Text = "O";
else if (r == 0)
button2.Text = "X";
button2.Enabled = false;
if (button1.Text == button2.Text & button2.Text == button3.Text & button1.Text == button3.Text)
MessageBox.Show("P1 WIN!");
}
private void button3_Click(object sender, EventArgs e)
{
int r;
c = c + 1;
r = c % 2;
label1.Text = Convert.ToString(r);
if (r == 1)
button3.Text = "O";
else if (r == 0)
button3.Text = "X";
button3.Enabled = false;
if (button1.Text == button2.Text & button2.Text == button3.Text & button1.Text == button3.Text)
MessageBox.Show("P1 WIN!");
}
{
int r;
c = c + 1;
r = c % 2;
label1.Text = Convert.ToString(r);
if (r == 1)
button3.Text = "O";
else if (r == 0)
button3.Text = "X";
button3.Enabled = false;
if (button1.Text == button2.Text & button2.Text == button3.Text & button1.Text == button3.Text)
MessageBox.Show("P1 WIN!");
}

沒有留言:
張貼留言