2010年10月1日 星期五

99/10/1作業 99乘法表

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 Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            int a1,an,d,n,sum;
            a1 = int.Parse(textBox1.Text);
           
            d = int.Parse(textBox2.Text);
            n = int.Parse(textBox3.Text);
           
            an = a1 + (n-1) * d;
            sum = (a1 + an) * n / 2;
            textBox4.Text = ""+an;
            textBox5.Text = "" + sum;
        }
        private void Form1_Load(object sender, EventArgs e)
        {
        }
        private void label2_Click(object sender, EventArgs e)
        {
        }
        private void button2_Click(object sender, EventArgs e)
        {
            int s;
            int[,] arr1=new int [101,101];
            for (int i = 1; i <= 9; i++)
            {
                for (int j = 1; j <= 9; j++)
                {
                    s =i*j;
                    arr1[i, j] = s;
                    listBox1.Items.Add("" + i + "*" + "" + j + "=" + arr1[i, j]);
                }
            }
        }
    }
}

沒有留言:

張貼留言