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
{
Form2 newform;
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)
{
}
private void button2_Click_1(object sender, EventArgs e)
{
newform = new Form2();
newform.Show();
}
}
}
第二表單
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 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]);
}
}
}
private void button2_Click_1(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]);
}
}
}
}
}
int[,] arr = new int[10, 10];
int sum = 0;
for (int j = 0; j < 9; j++)
for (int k = 0; k < 9; k++)
{
arr[j, k] = (j + 1) * (k + 1);
sum = arr[j, k];
//listBox1.Items.Add("arr[" + (j + 1) + "]" + "[" + (k + 1) + "]=" + sum);
}
for (int j = 0; j < 9; j++)
{
listBox1.Items.Add("" + arr[j, 0] + "," + arr[j, 1] + "," + arr[j, 2] + "," + arr[j, 3] + "," + arr[j, 4] + "," + arr[j, 5] + "," + arr[j, 6] + "," + arr[j, 7] + "," + arr[j, 8]);
}
沒有留言:
張貼留言