Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace Rozwiązywanie_układów_liniowych
  11. {
  12. public partial class Form1 : Form
  13. {
  14. public Form1()
  15. {
  16. InitializeComponent();
  17. }
  18.  
  19. private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
  20. {
  21.  
  22. }
  23.  
  24. private void button1_Click(object sender, EventArgs e)
  25. {
  26. int N = (int)numericUpDown1.Value;
  27.  
  28. dataGridView1.RowCount = (N + 1);
  29. dataGridView1.ColumnCount = (N + 1);
  30.  
  31. dataGridView2.RowCount = N + 1;
  32.  
  33. dataGridView3.RowCount = N + 1;
  34.  
  35. Random rand = new Random();
  36. Random x = new Random();
  37. double randx;
  38.  
  39. double[,] A = new double[N+1,N+1];
  40. double[] B = new double[N + 1];
  41. double[] X = new double[N + 1];
  42. for (int i = 1; i <N+1; i++)
  43. {
  44. randx=x.Next(10)+2;
  45. B[i] = 0;
  46. for(int j = 1;j<N+1;j++)
  47. {
  48. A[i,j] = rand.Next(100);
  49. B[i] += randx * A[i, j];
  50. }
  51.  
  52. }
  53.  
  54. for (int i = 1; i < N + 1; i++)
  55. {
  56. dataGridView3.Rows[i].Cells[0].Value = B[i].ToString();
  57. for (int j = 1; j < N + 1; j++)
  58. {
  59. dataGridView1.Rows[i].Cells[j].Value = A[i,j].ToString();
  60.  
  61. }
  62. }
  63. MetodyNumeryczne.MetodaGaussa.Gauss(A, B, X, 1e-30);
  64.  
  65. for (int i = 1; i < N + 1; i++)
  66. {
  67. dataGridView2.Rows[i].Cells[0].Value = X[i].ToString();
  68. }
  69.  
  70.  
  71.  
  72. }
  73.  
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement