using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _01_1_Testy
{
  public partial class Form1 : Form
  {

    Random rnd = new Random();


    public Form1()
    {
      InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
      MessageBox.Show("Hello world!");
    }

    private void button2_Click(object sender, EventArgs e)
    {
      double[,] A = new double[5, 5];
      
      for (int i = 0; i < 5; i++)
        for (int j = 0; j < 5; j++)
          A[i, j] = 10 * rnd.NextDouble() - 5;

      for (int i = 0; i < 5; i++)
      {
        for (int j = 0; j < 5; j++)
          textBox1.AppendText($" {A[i, j],5:f2}");
        textBox1.AppendText("\r\n");
      }
    }

    private void button3_Click(object sender, EventArgs e)
    {
      double[] V = new double[5];
      for (int i = 0; i < 5; i++)
        V[i] = 40 * rnd.NextDouble() + 10;

      for (int i = 0; i < 5; i++)      
        textBox1.AppendText($"{V[i]}\r\n");
      

    }

    private void button4_Click(object sender, EventArgs e)
    {
      Form2 f2 = new Form2();
      int n = 100;
      double[] x = new double[n];
      double[] y = new double[n];
      for (int i = 0; i < n; i++)
      {
        x[i] = rnd.NextDouble();
        y[i] = 2 * x[i] * x[i] - 0.5 * x[i] + 7;
      }

      for (int i = 0; i < n; i++)
      {
        f2.chart1.Series[0].Points.AddXY(x[i], y[i]);
      }

      f2.Show();
    }
  }
}
