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_2_Testy
{
  public partial class Form1 : Form
  {

    Random r = 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[] V = new double[10];

      for (int i = 0; i < V.Length; i++)
      {
        V[i] = 20 * r.NextDouble() - 10;
      }

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

    }

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

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

    }

    private void button4_Click(object sender, EventArgs e)
    {
      int n = 100;
      double[] x = new double[n];
      double[] y = new double[n];
      for (int i = 0; i < n; i++)
      {
        x[i] = r.NextDouble();
        y[i] = Math.Sin(6 * x[i]);
      }

      Form2 f2 = new Form2();

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

      f2.Show();

    }
  }
}
