2010年10月1日 星期五

九九乘法表listBox1

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 Form1t : Form
    {
        public Form1t()
        {
            InitializeComponent();
        }
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
        }
        private void button2_Click(object sender, EventArgs e)
        {
            {
            int sum = 0;
            int[,] arr2 = new int[10, 10];
            for (int i = 1; i <= 9; i++)
                for (int j = 1; j <= 9; j++)
                {
                    sum = i * j;
                    arr2[i, j] = sum;
                }
            for (int i = 1; i <= 9; i++)
                {
                    listBox1.Items.Add(+i + "*" + 1 + "=" + arr2[i, 1]+"," +i + "*" + 2 + "=" + arr2[i, 2]
                        + "," + i + "*" + 3 + "=" + arr2[i, 3] + "," + i + "*" + 4 + "=" + arr2[i, 4]
                        + "," + i + "*" + 5 + "=" + arr2[i, 5] + "," + i + "*" + 6 + "=" + arr2[i, 6]
                        + "," + i + "*" + 7 + "=" + arr2[i, 7] + "," + i + "*" + 8 + "=" + arr2[i, 8]
                        + "," + i + "*" + 9 + "=" + arr2[i, 9]);
                }
        }
       
        }
    }
}

沒有留言:

張貼留言