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 label2_Click(object sender, EventArgs e)
{
}
private void textBox4_TextChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
int a1, an, n, d, sn;
a1 = int.Parse(textBox1.Text);
d = int.Parse(textBox2.Text);
n = int.Parse(textBox3.Text);
an = a1 + (n - 1) * d;
sn = n / 2 * (2 * a1 + (n - 1) * d);
textBox4.Text = "" + an;
textBox5.Text = "" + sn;
}
private void button2_Click(object sender, EventArgs e)
{
int[,] arr1 = new int[10, 10];
int[,] arr2 = new int[10, 10];
int[,] arr3 = new int[10, 10];
int[,] arr4 = new int[10, 10];
int[,] arr5 = new int[10, 10];
int[,] arr6 = new int[10, 10];
int[,] arr7 = new int[10, 10];
int[,] arr8 = new int[10, 10];
int[,] arr9 = new int[10, 10];
for (int i = 1; i <= 9; i++)
{
for (int j = 1; j <= 9; j++)
{
arr1[i, j] = 1 * j;
arr2[i, j] = 2 * j;
arr3[i, j] = 3 * j;
arr4[i, j] = 4 * j;
arr5[i, j] = 5 * j;
arr6[i, j] = 6 * j;
arr7[i, j] = 7 * j;
arr8[i, j] = 8 * j;
arr9[i, j] = 9 * j;
}
}
for (int i = 1; i <= 9; i++)
{
for (int j = 1; j <= 9; j++)
{
Console.WriteLine(+i + "*" + j + "=" + arr1[i, j]);
listBox1.Items.Add(+1 + "*" + j + "=" + arr1[i, j]
+ " " + 2 + "*" + j + "=" + arr2[i, j]
+ " " + 3 + "*" + j + "=" + arr3[i, j]
+ " " + 4 + "*" + j + "=" + arr4[i, j]
+ " " + 5 + "*" + j + "=" + arr5[i, j]
+ " " + 6 + "*" + j + "=" + arr6[i, j]
+ " " + 7 + "*" + j + "=" + arr7[i, j]
+ " " + 8 + "*" + j + "=" + arr8[i, j]
+ " " + 9 + "*" + j + "=" + arr9[i, j]);
}
}
}
}
}
沒有留言:
張貼留言