Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Uklady_liniowe_Re
- {
- public partial class Form1 : Form
- {
- int N;
- double[,] A;
- double[] B, X;
- string TypMacierzy;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- numericUpDown1_ValueChanged(sender, e);
- }
- private void button1_Click(object sender, EventArgs e)
- {
- double Ax, suma = 0;
- Random R = new Random();
- TypMacierzy = "rzeczywista";
- A = new Double[N + 1, N + 1];
- B = new Double[N + 1];
- X = new Double[N + 1];
- for(int i=1; i<=N; i ++)
- {
- suma = 0;
- for(int j=1; j<=N; j++){
- Ax = R.Next(1,10);
- if(i!=j)
- {
- MacierzA[j-1, i-1].Value = Ax.ToString();
- A[i,j] = Ax;
- suma += Ax;
- }
- else
- {
- MacierzA[j-1, i-1].Value = (10.0 * Ax).ToString();
- A[i,j] = 10.0 * Ax;
- suma += 10.0 * Ax;
- }
- }
- B[i]=suma;
- WektorB[0, i -1].Value = suma.ToString();
- }
- button2.Enabled = true;
- }
- private void numericUpDown1_ValueChanged(object sender, EventArgs e)
- {
- N = (int)numericUpDown1.Value;
- ustawTablice();
- }
- private void ustawTablice()
- {
- MacierzA.ColumnCount = N;
- MacierzA.RowCount = N;
- WektorX.RowCount = N;
- WektorB.RowCount = N;
- for (int i = 0; i < N; i++)
- {
- MacierzA.Columns[i].HeaderText = (i + 1).ToString();
- MacierzA.Rows[i].HeaderCell.Value = (i + 1).ToString();
- MacierzA.Columns[i].Width = 35;
- }
- }
- private void MacierzA_Scroll(object sender, ScrollEventArgs e)
- {
- WektorX.FirstDisplayedScrollingRowIndex = WektorB.FirstDisplayedScrollingRowIndex
- = MacierzA.FirstDisplayedScrollingRowIndex;
- }
- private void button2_Click(object sender, EventArgs e)
- {
- int blad = 0;
- if (TypMacierzy == "rzeczywista")
- {
- if (radioButton1.Checked) blad = Class1.RozRowMacGaussa(A, B, X, 1e-30);
- //jakas insturkteutac glupia byla
- if (blad == 0)
- for (int i = 1; i <= N; i++)
- WektorX[0, i - 1].Value = X[i].ToString("0.000000");
- }
- // else{
- // if(radioButton1.Checked) blad = Class1.RozRowMacGaussa(A, B, X, 1e-30);
- //znowu ta instrukacj
- // if(blad==0)
- }
- }
- }
Add Comment
Please, Sign In to add comment