2010年10月8日 星期五

第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 WindowsFormsApplication1
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {

            int a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0, a7 = 0, a8 = 0, a9 = 0;
            int b1 = 0, b2 = 0, b3 = 0, b4 = 0, b5 = 0, b6 = 0, b7 = 0, b8 = 0, b9 = 0;
            int c1 = 0, c2 = 0, c3 = 0, c4 = 0, c5 = 0, c6 = 0, c7 = 0, c8 = 0, c9 = 0;
            int[,] a = new int[3, 3];
            int[,] b = new int[3, 3];
            int[,] c = new int[3, 3];
            String output;
           
          
           

            a1 = int.Parse(textBox1.Text);
            a2 = int.Parse(textBox2.Text);
            a3 = int.Parse(textBox3.Text);
            a4 = int.Parse(textBox4.Text);
            a5 = int.Parse(textBox5.Text);
            a6 = int.Parse(textBox6.Text);
            a7 = int.Parse(textBox7.Text);
            a8 = int.Parse(textBox8.Text);
            a9 = int.Parse(textBox.Text);
           
            b1 = int.Parse(textBox10.Text);
            b2 = int.Parse(textBox11.Text);
            b3 = int.Parse(textBox12.Text);
            b4 = int.Parse(textBox13.Text);
            b5 = int.Parse(textBox14.Text);
            b6 = int.Parse(textBox15.Text);
            b7 = int.Parse(textBox16.Text);
            b8 = int.Parse(textBox17.Text);
            b9 = int.Parse(textBox18.Text);

            c1 = a1 * b1 + a4 * b2 + a7 * b3;
            c2 = a2 * b1 + a5 * b2 + a8 * b3;
            c3 = a3 * b1 + a6 * b2 + a9 * b3;
            c4 = a1 * b4 + a4 * b5 + a7 * b6;
            c5 = a2 * b4 + a5 * b5 + a8 * b6;
            c6 = a3 * b4 + a6 * b5 + a9 * b6;
            c7 = a1 * b7 + a4 * b8 + a7 * b9;
            c8 = a2 * b7 + a5 * b8 + a8 * b9;
            c9 = a3 * b7 + a6 * b8 + a9 * b9;
           
            output = Convert.ToString(c1);
            textBox19.Text = Convert.ToString(c1);
            output = Convert.ToString(c2);
            textBox20.Text = Convert.ToString(c2);
            output = Convert.ToString(c3);
            textBox21.Text = Convert.ToString(c3);
            output = Convert.ToString(c4);
            textBox22.Text = Convert.ToString(c4);
            output = Convert.ToString(c5);
            textBox23.Text = Convert.ToString(c5);
            output = Convert.ToString(c6);
            textBox24.Text = Convert.ToString(c6);
            output = Convert.ToString(c7);
            textBox25.Text = Convert.ToString(c7);
            output = Convert.ToString(c8);
            textBox26.Text = Convert.ToString(c8);
            output = Convert.ToString(c9);
            textBox27.Text = Convert.ToString(c9);


        }
    }
}

沒有留言:

張貼留言