2014年12月26日 星期五

4*4數字盤推(中)

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 WindowsFormsApplication24
{
    public partial class Form1 : Form
    {
        Button[,] buttons = new Button[10, 10];
        int[] array = new int[10];

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            int d1, tmp, k;

            Random irand = new Random();
            d1 = irand.Next(1, 10);
            label1.Text = d1.ToString();


            for (int j = 1; j < 10; j++)
            {
                k = 9 - j + 1;
                tmp = array[d1];
                array[d1] = array[k];
                array[k] = tmp;
            }


            for (int j = 0; j < 3; j++)
            {
                for (int i = 0; i < 3; i++)
                {
                    //buttons[i, j] = new Button();
                    buttons[i, j].Location = new Point(j * 50, i * 50);
                    buttons[i, j].Text = array[i * 3 + j + 1].ToString();
                    this.Controls.Add(buttons[i, j]);
                }

            }
        }
        private void movement(int i, int j, string s) {
            MessageBox.Show("i=" + i + ",j" + j + "" + s);

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // Instantiating all the buttons in the array



            for (int i = 0; i < 9; i++)
            {
                array[i] = i;
            }


            /*
            for (int j = 1; j < 10; j++)
            {
                buttons[1, j] = new Button();
                buttons[1, j].Location = new Point(50 * j, 50);
                buttons[1, j].Text = array[j].ToString();
                this.Controls.Add(buttons[1, j]);
            }
            */

            for (int j = 0; j < 3; j++)
            {
                for (int i = 0; i < 3; i++)
                {
                    buttons[i, j] = new Button();
                    buttons[i, j].Location = new Point(j * 50, i * 50);
                    buttons[i, j].Text = (j * 3 + i).ToString();
                    this.Controls.Add(buttons[i, j]);
                    buttons[i, j].Click += new EventHandler(Button1_Click);
                }

            }
           
        }
        private void Button1_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (buttons[i, j].Text == "0")
                    {
                        MessageBox.Show("i=" + i + ",j=" + j + " " + buttons[i, j].Text);
                    }
                }


            }




            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    if (sender == buttons[i, j])
                    {
                        MessageBox.Show("i=" + i + ",j=" + j + " " + buttons[i, j].Text);
                    }
                }


            }




        }
    }
}

2014年12月19日 星期五

4*4數字盤推(前)(變身版)

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 WindowsFormsApplication22
{
    public partial class Form1 : Form
    {
        Button[,] buttons = new Button[17, 17];//格子,自己去試拉我不說
        int[] array = new int[17];
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            for (int i = 0; i < 16; i++)
            {
                array[i] = i;//這不是陣列(?!!
            }


            /*
            for (int j = 1; j < 10; j++)
            {
                buttons[1, j] = new Button();
                buttons[1, j].Location = new Point(50 * j, 50);
                buttons[1, j].Text = array[j].ToString();
                this.Controls.Add(buttons[1, j]);
            }
            */

            for (int j = 0; j < 4; j++)
            {
                for (int i = 0; i < 4; i++)
                {
                    buttons[i, j] = new Button();
                    buttons[i, j].Location = new Point(j * 50, i * 50);
                    buttons[i, j].Text = (j * 4 + i).ToString();
                    this.Controls.Add(buttons[i, j]);
                    buttons[i, j].Click += new EventHandler(        Button1_Click);//大小寫的Bb都可以放哈,很好玩(?!
                }
            }
        }
        private void Button1_Click(object sender, EventArgs e)//此乃,俺爭家的,不速理免有低
        {
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    if (buttons[i, j].Text == "0")
                    {
                        MessageBox.Show("i=" + i + ",j=" + j + " " + buttons[i, j].Text);
                    }
                }


            }




            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    if (sender == buttons[i, j])
                    {
                        MessageBox.Show("i=" + i + ",j=" + j + " " + buttons[i, j].Text);
                    }
                }


            }
        }  
        private void button1_Click(object sender, EventArgs e)//這個好像是..本身用程式碼打出來的格子
        {
             int d1, tmp, k;

            Random irand = new Random();
            d1 = irand.Next(1, 16);
            label1.Text = d1.ToString();


            for (int j = 1; j < 16; j++)
            {
                k = 16 - j + 1;
                tmp = array[d1];
                array[d1] = array[k];
                array[k] = tmp;
            }


            for (int j = 0; j < 4; j++)
            {
                for (int i = 0; i < 4; i++)
                {
                    buttons[i, j].Size = new System.Drawing.Size(100, 100);
                    //buttons[i, j] = new Button();
                   buttons[i, j].BackColor = Color.Yellow;

                   buttons[i, j].Location = new Point(  j * 100,  i * 100);
                 
                    buttons[i, j].Text = array[i*4+j+1].ToString();
                 
                    this.Controls.Add(buttons[i, j]);
                }
            }






            //buttons[1, 1].Text = array[1].ToString();

            /*
            for (int j = 1; j < 10; j++)
            {
                //    buttons[1, j] = new Button();
                buttons[1, j].Location = new Point(50 * j, 50);
                buttons[1, j].Text = array[j].ToString();
                this.Controls.Add(buttons[1, j]);
            }
             */


            label2.Text = array[d1].ToString();

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
        }
 

2014年12月11日 星期四

切切切聽說這個是亂數的拉

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 WindowsFormsApplication11
{
    public partial class Form1 : Form
    {    string c;
        int[] a = new int[10];
        Button[,] b = new Button[5, 5];
        int[,] w=new int[5,5];
        Random r1 = new Random();
     
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            for (int j = 0; j < 5; j++)
            {
                for (int i = 0; i < 5; i++)
                {
                    b[i, j] = new System.Windows.Forms.Button();
                    b[i, j].Location = new Point(50 * i, 50 * j);
                    b[i, j].Click += new EventHandler(b_Click);
                    b[i, j].Width = 50;
                    b[i, j].Height = 50;
                    b[i, j].Text = "" + (i + j * 5);
                    w[i, j] = i + j * 5;//w[i,j]可以用來紀錄b[i,j]有關的數值
                    this.Controls.Add(b[i, j]);

                }
            }
            for (int j = 0; j < 25; j++)
            {
                for (int i = 0; i < j; i++)
                {
                    a[0] = r1.Next(0, j);//a[0]從0到j
                    a[1] = a[0] % 5;//a[1],a[2]從0到4
                    a[2] = (a[0] - a[1]) / 5;
                    c = b[a[1], a[2]].Text;
                    b[a[1], a[2]].Text = b[i % 5, i / 5].Text;
                    b[i % 5, i / 5].Text = c;//被隨機到的按鈕與第i個交換名稱

                }
            }
        }
        private void b_Click(object sender, EventArgs e) { }
  private void button1_Click(object sender, EventArgs e)
        {
            for (int j = 0; j < 25; j++)
            {
                for (int i = 0; i < j; i++)
                {
                    a[0] = r1.Next(0, j);
                    a[1] = a[0] % 5;
                    a[2] = (a[0] - a[1]) / 5;
                    c = b[a[1], a[2]].Text;
                    b[a[1], a[2]].Text = b[i % 5, i / 5].Text;
                    b[i % 5, i / 5].Text = c;
                }
            }
        }
    }
}

2014年11月28日 星期五

我忘了...

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 WindowsFormsApplication13
{
    public partial class Form1 : Form
    {

        Button[,] Buttons =new Button[5,5];//5*5格子
     
        Random irand = new Random(Guid.NewGuid().GetHashCode());
     





        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
           // APPLE();

            int a = 70;
            int b = 60;

            int r;
            for (int i = 1; i < 5; i++)
            {
                for (int j = 1; j < 5; j++)
                {
                    Random irand = new Random(Guid.NewGuid().GetHashCode());
                    Buttons[i, j] = new Button();
                    Buttons[i, j].Location = new Point(i * 60, j * 70 + 10);//算格子堅格寬度
                    this.Controls.Add(Buttons[i, j]);
                    Buttons[i, j].Size = new System.Drawing.Size(a, b);
                    r = irand.Next(0, 15);
                    Buttons[i, j].Text = r.ToString();//轉,顯示



//以下是其他的東西有興趣可以用來玩玩

                    // Button1 = new System.Windows.Forms.Button();
                    // Button1.Location = new Point(100, 100);
                    //Button1.Size = new System.Drawing.Size(200, 200);
                    //Button1.Click += new EventHandler(Button1_Click);
                    //Button1.BackColor = Color.Green;
                    // this.Controls.Add(Button1);

                }
            }
        }
//        private void APPLE()
  //      {
    //        int r;
     
         // Button1 = new System.Windows.Forms.Button();
           // Button1.Location = new Point(100, 100);
          //  Button1.Size = new System.Drawing.Size(200, 200);
           // this.Controls.Add(Button1);
      //    int width, height;
         
        //    width = this.Size.Width;
          //  height = this.Size.Height;

            //Buttons = new System.Windows.Forms.Button[16];

         //   width= 100;
          //  height= 100;



        //    for (int i = 0; i < 16; ++i)
          //  {
             

            //    Random irand = new Random(Guid.NewGuid().GetHashCode());
             
              //  Buttons[i] = new Button();

                //this.Controls.Add(Buttons[i]);


             

                  //  Buttons[i].Location = new System.Drawing.Point(300 + i * 100, 100);
                //else if (i > 3 && i <= 7)
                 //   Buttons[i].Location = new System.Drawing.Point(200 + (i - 3) * 100, 200);
               // else if (i > 7 && i <= 11)
                //    Buttons[i].Location = new System.Drawing.Point(100 + (i - 6) * 100, 300);
               // else if (i > 11 && i <= 16)
                 //   Buttons[i].Location = new System.Drawing.Point(0 + (i - 9) * 100, 400);

                //Buttons[i].Text = irand.ToString();
               //r=irand.Next(0,15);
               // Buttons[i].Size = new Size(width, height);
               // Buttons[i].Size = new System.Drawing.Size(100, 100);
              //  Buttons[i].BackColor = Color.Green;
               // Buttons[i].Click += new EventHandler(Buttons_Click);

            }
        }


//private void Buttons_Click(object sender, EventArgs e)
  //      {

    //                 Button btn = (Button)sender;
      //      MessageBox.Show(btn.Text);
        //    for (int i = 0; i < 16; ++i)
          //  {
            //    Buttons[i] = new Button();
                       
              //  this.Controls.Add(Buttons[i]);              
             
            //}
        //}
    //}
//}

2014年11月24日 星期一

聊天室建置配方-1

<html>
<head>
<meta http-equiv="refresh"content="1" />
</head>


<body>
<font color="red"今天日期:><?php date_default_timezone_set("Hongkong");
echo date("Y-m-d");?></font>
<br>
<font color="blue">現在時間:<?php echo date("h-i-s");?>
</body>
</html>

2014年11月20日 星期四

計算機


網址連結   程式設計工藝大師 http://tccnchsu.blogspot.tw/



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 _1
{
public partial class Form1 : Form
{
int a = 0, b = 0,i=4;
float a1 = 0, b1 = 0, c1 = 1;
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
textBox2.Text ="+";
if (a == 0) {
a = 1;
textBox2.Visible = true;
textBox3.Visible = true;
b = 0;
button17.Enabled = true;
c1 = 1;
}
i = 0;
}

private void button2_Click(object sender, EventArgs e)
{
textBox2.Text ="-";
if (a == 0)
{
a = 1;
textBox2.Visible = true;
textBox3.Visible = true;
b = 0;
button17.Enabled = true;
c1 = 1;
}
i = 1;
}

private void button3_Click(object sender, EventArgs e)
{
textBox2.Text ="*";
if (a == 0)
{
a = 1;
textBox2.Visible = true;
textBox3.Visible = true;
b = 0;
button17.Enabled = true;
c1 = 1;
}
i = 2;
}

private void button4_Click(object sender, EventArgs e)
{
textBox2.Text ="/";
if (a == 0)
{
a = 1;
textBox2.Visible = true;
textBox3.Visible = true;
b = 0;
button17.Enabled = true;
c1 = 1;
}
i = 3;
}
private void button5_Click(object sender, EventArgs e)
{
textBox1.Text = "";
textBox2.Text = "";
textBox3.Text = "";
textBox4.Text = "";
a = 0;
b = 0;
a1 = 0;
b1 = 0;
c1 = 1;
i = 4;
textBox2.Visible = false;
textBox3.Visible = false;
textBox4.Visible = false;
button17.Enabled = true;
}

private void button8_Click(object sender, EventArgs e)
{
add(1);
}

private void button9_Click(object sender, EventArgs e)
{
add(2);
}

private void button10_Click(object sender, EventArgs e)
{
add(3);
}

private void button11_Click(object sender, EventArgs e)
{
add(4);
}

private void button12_Click(object sender, EventArgs e)
{
add(5);
}

private void button13_Click(object sender, EventArgs e)
{
add(6);
}

private void button14_Click(object sender, EventArgs e)
{
add(7);
}

private void button15_Click(object sender, EventArgs e)
{
add(8);
}

private void button16_Click(object sender, EventArgs e)
{
add(9);
}

private void button17_Click(object sender, EventArgs e)
{
b = 1;
button17.Enabled = false;
if (a == 0) { textBox1.Text = textBox1.Text + "."; }
if (a == 1)
{
textBox3.Text = textBox3.Text + ".";
}
}

private void button7_Click(object sender, EventArgs e)
{
textBox4.Visible = true;
if (i == 0)
{
c1=a1+b1;
textBox4.Text = ""+c1;
}
if (i == 1)
{
c1 = a1 - b1;
textBox4.Text = "" + c1;
}
if (i == 2)
{
c1 = a1 * b1;
textBox4.Text = "" + c1;
}
if (i == 3)
{
if (b1 != 0)
{
c1 = a1 / b1;
textBox4.Text = "" + c1;
}
else if (b1 == 0) { textBox4.Text = "error!"; }
}
}

private void add(int i)
{
if (a == 0)
{
textBox1.Text = textBox1.Text +i;
if (b == 0)
{
a1 = a1 * 10 + i;
}
if (b == 1)
{
c1 = c1 / 10;
a1 = a1 + i * c1;
}
}
if (a == 1)
{
textBox3.Text = textBox3.Text+i ;
if (b == 0)
{
b1 = b1 * 10 + i;
}
if (b == 1)
{
c1 = c1 / 10;
b1 = b1 + i * c1;
}
}
}

private void button6_Click(object sender, EventArgs e)
{
add(0);
}
}
}