111,125
社区成员
发帖
与我相关
我的任务
分享

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 计算器
{
public partial class juzhen : Form
{
public juzhen()
{
InitializeComponent();
}
private void juzhen_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox5_TextChanged(object sender, EventArgs e)
{
}
private void label2_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
if (textBox6 != null)//文本框清空
{
textBox6.Text = "";
}
if (string.IsNullOrEmpty(textBox1.Text) && string.IsNullOrEmpty(textBox2.Text))
{ MessageBox.Show("输入不能为空"); }
else
{
int a = Convert.ToInt32(textBox3.Text);
int b = Convert.ToInt32(textBox4.Text);
string text1 = textBox1.Text;
string text2 = textBox2.Text;
string text3 = textBox3.Text;
string strm = "";
char[] sp = new char[3] { ' ', '\t','\n'};
string[] str1 = textBox1.Text.Split(sp);
string[] str2 = textBox2.Text.Split(sp);
int[,] intArray1 = new int[a, b];
int[,] intArray2 = new int[a, b];
int[,] intArray3 = new int[a, b];
string[] arr = new string[textBox1.Lines.Length];
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
{
int m = a*b+j;
if (m % 4 == 0) m++;
intArray1[i, j] = int.Parse(str1[m]);
}
}
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
{
int m = a * b + j;
intArray2[i, j] = int.Parse(str2[m]);
}
}
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
{
strm += Convert.ToString(intArray1[i, j] + intArray2[i, j]);
}
}
for(int x = 0; x < a; x++)
{
textBox6.Text += strm;
}
}
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
if (textBox6 != null)//文本框清空
{
textBox6.Text = "";
}
if (string.IsNullOrEmpty(textBox1.Text) && string.IsNullOrEmpty(textBox2.Text))
{ MessageBox.Show("输入不能为空"); }
else
{
int a = Convert.ToInt32(textBox3.Text);
int b = Convert.ToInt32(textBox4.Text);
string text1 = textBox1.Text;
string text2 = textBox2.Text;
string text3 = textBox3.Text;
string strm = "";
char[] sp = new char[3] { ' ', '\t', '\n' };
string[] str1 = textBox1.Text.Split(sp);
string[] str2 = textBox2.Text.Split(sp);
int[,] intArray1 = new int[a, b];
int[,] intArray2 = new int[a, b];
int[,] intArray3 = new int[a, b];
string[] arr = new string[textBox1.Lines.Length];
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
{
int m = a * b + j;
if (m % 4 == 0) m++;
intArray1[i, j] = int.Parse(str1[m]);
}
}
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
{
int m = a * b + j;
intArray2[i, j] = int.Parse(str2[m]);
}
}
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
{
strm += Convert.ToString(intArray1[i, j] - intArray2[i, j]);
}
}
for (int x = 0; x < a; x++)
{
textBox6.Text += strm;
}
}
}
private void button3_Click(object sender, EventArgs e)
{
if (textBox6 != null)//文本框清空
{
textBox6.Text = "";
}
if (string.IsNullOrEmpty(textBox1.Text) && string.IsNullOrEmpty(textBox2.Text))
{ MessageBox.Show("输入不能为空"); }
else
{
int a = Convert.ToInt32(textBox3.Text);
int b = Convert.ToInt32(textBox4.Text);
string text1 = textBox1.Text;
string text2 = textBox2.Text;
string text3 = textBox3.Text;
string strm = "";
char[] sp = new char[3] { ' ', '\t', '\n' };
string[] str1 = textBox1.Text.Split(sp);
string[] str2 = textBox2.Text.Split(sp);
int n=0;
int[,] intArray1 = new int[a, b];
int[,] intArray2 = new int[a, b];
int[,] intArray3 = new int[a, b];
string[] arr = new string[textBox1.Lines.Length];
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
{
int m = a * b + j;
if (m % 4 == 0) m++;
intArray1[i, j] = int.Parse(str1[m]);
}
}
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
{
int m = a * b + j;
intArray2[i, j] = int.Parse(str2[m]);
}
}
if(a!=b)
{
MessageBox.Show("前列要等于后行");
}
else
{
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
{
for (int x = 0; x < b; x++)
{
n= intArray1[x, j] * intArray2[j, x];
}
strm += Convert.ToString(n);
}
}
for (int x = 0; x < a; x++)
{
textBox6.Text += strm;
}
}
}
}
private void button4_Click(object sender, EventArgs e)
{
if (textBox6 != null)//文本框清空
{
textBox6.Text = "";
}
if (string.IsNullOrEmpty(textBox1.Text) && string.IsNullOrEmpty(textBox2.Text))
{ MessageBox.Show("输入不能为空"); }
else
{
int a = Convert.ToInt32(textBox3.Text);
int b = Convert.ToInt32(textBox4.Text);
string text1 = textBox1.Text;
string text2 = textBox2.Text;
string text3 = textBox3.Text;
string strm = "";
char[] sp = new char[3] { ' ', '\t', '\n' };
string[] str1 = textBox1.Text.Split(sp);
string[] str2 = textBox2.Text.Split(sp);
int[,] intArray1 = new int[a, b];
int[,] intArray2 = new int[a, b];
int[,] intArray3 = new int[a, b];
string[] arr = new string[textBox1.Lines.Length];
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
{
int m = a * b + j;
if (m % 4 == 0) m++;
intArray1[i, j] = int.Parse(str1[m]);
}
}
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
{
int m = a * b + j;
intArray2[i, j] = int.Parse(str2[m]);
}
}
for (int i = 0; i < a; i++)
{
for (int j = 0; j < b; j++)
{
strm += Convert.ToString(intArray1[j, i]);
}
}
for (int x = 0; x < a; x++)
{
textBox6.Text += strm;
}
for (int x = 0; x < a; x++)
{
textBox6.Text += strm;
}
}
}
}
}
