Form1.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace _01_1_Testy
  11. {
  12. public partial class Form1 : Form
  13. {
  14. Random rnd = new Random();
  15. public Form1()
  16. {
  17. InitializeComponent();
  18. }
  19. private void button1_Click(object sender, EventArgs e)
  20. {
  21. MessageBox.Show("Hello world!");
  22. }
  23. private void button2_Click(object sender, EventArgs e)
  24. {
  25. double[,] A = new double[5, 5];
  26. for (int i = 0; i < 5; i++)
  27. for (int j = 0; j < 5; j++)
  28. A[i, j] = 10 * rnd.NextDouble() - 5;
  29. for (int i = 0; i < 5; i++)
  30. {
  31. for (int j = 0; j < 5; j++)
  32. textBox1.AppendText($" {A[i, j],5:f2}");
  33. textBox1.AppendText("\r\n");
  34. }
  35. }
  36. private void button3_Click(object sender, EventArgs e)
  37. {
  38. double[] V = new double[5];
  39. for (int i = 0; i < 5; i++)
  40. V[i] = 40 * rnd.NextDouble() + 10;
  41. for (int i = 0; i < 5; i++)
  42. textBox1.AppendText($"{V[i]}\r\n");
  43. }
  44. private void button4_Click(object sender, EventArgs e)
  45. {
  46. Form2 f2 = new Form2();
  47. int n = 100;
  48. double[] x = new double[n];
  49. double[] y = new double[n];
  50. for (int i = 0; i < n; i++)
  51. {
  52. x[i] = rnd.NextDouble();
  53. y[i] = 2 * x[i] * x[i] - 0.5 * x[i] + 7;
  54. }
  55. for (int i = 0; i < n; i++)
  56. {
  57. f2.chart1.Series[0].Points.AddXY(x[i], y[i]);
  58. }
  59. f2.Show();
  60. }
  61. }
  62. }