Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Windows.Forms;
- using System.IO;
- namespace Сложение_матриц
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- {
- {
- StreamReader fileReader = new StreamReader("d:/1111.txt");
- string isxodFile = fileReader.ReadToEnd();
- fileReader.Close();
- string[] fileMatrix = isxodFile.Split(new[] { "\r\n\r\n" }, StringSplitOptions.None);
- string[] ur_1 = fileMatrix[0].Split('\n');
- string[] ur_2 = fileMatrix[1].Split('\n');
- string[] line = ur_1[0].Split(' ');
- int[,] matrix_1 = new int[ur_1.Length, line.Length];
- int[,] matrix_2 = new int[ur_2.Length, line.Length];
- for (int i = 0; i < ur_1.Length; i++)
- {
- line = ur_1[i].Split(' ');
- for (int j = 0; j < line.Length; j++)
- matrix_1[i, j] = Convert.ToInt16(line[j]);
- line = ur_2[i].Split(' ');
- for (int j = 0; j < line.Length; j++)
- {
- matrix_2[i, j] = Convert.ToInt16(line[j]);
- richTextBox1.Text += Convert.ToString(matrix_1[i, j] + matrix_2[i, j]) + '\t';
- }
- richTextBox1.Text += '\n';
- }
- }
- }
- }
- private void открытьToolStripMenuItem_Click(object sender, EventArgs e)
- {
- openFileDialog1.Filter = " Текстовый фйл| *.txt";
- if (openFileDialog1.ShowDialog() == DialogResult.OK)
- richTextBox1.LoadFile(openFileDialog1.FileName, RichTextBoxStreamType.PlainText);
- }
- private void СохранитьToolStripMenuItem_Click(object sender, EventArgs e)
- {
- saveFileDialog1.Filter = " Текстовый фйл| *.txt";
- if (saveFileDialog1.ShowDialog() == DialogResult.OK)
- richTextBox1.SaveFile(saveFileDialog1.FileName, RichTextBoxStreamType.PlainText);
- }
- private void выходToolStripMenuItem1_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- private void справкаToolStripMenuItem1_Click(object sender, EventArgs e)
- {
- MessageBox.Show("Выберете файл с 2 матрицами,разделенными пустой строкой,затем нажмите сумма или разность.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement