Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 Rozwiązywanie_układów_liniowych
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- int N = (int)numericUpDown1.Value;
- dataGridView1.RowCount = (N + 1);
- dataGridView1.ColumnCount = (N + 1);
- dataGridView2.RowCount = N + 1;
- dataGridView3.RowCount = N + 1;
- Random rand = new Random();
- Random x = new Random();
- double randx;
- double[,] A = new double[N+1,N+1];
- double[] B = new double[N + 1];
- double[] X = new double[N + 1];
- for (int i = 1; i <N+1; i++)
- {
- randx=x.Next(10)+2;
- B[i] = 0;
- for(int j = 1;j<N+1;j++)
- {
- A[i,j] = rand.Next(100);
- B[i] += randx * A[i, j];
- }
- }
- for (int i = 1; i < N + 1; i++)
- {
- dataGridView3.Rows[i].Cells[0].Value = B[i].ToString();
- for (int j = 1; j < N + 1; j++)
- {
- dataGridView1.Rows[i].Cells[j].Value = A[i,j].ToString();
- }
- }
- MetodyNumeryczne.MetodaGaussa.Gauss(A, B, X, 1e-30);
- for (int i = 1; i < N + 1; i++)
- {
- dataGridView2.Rows[i].Cells[0].Value = X[i].ToString();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement