Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 Zadania1z1
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Random rnd = new Random();
- double liczbaM = double.Parse(textBox1.Text);
- double liczbaZ = double.Parse(textBox2.Text);
- double pomylka = 333333.333333*(liczbaZ/(double)100);
- double dolnaGranica, gornaGranica;
- dolnaGranica = 333333.333333 - pomylka;
- gornaGranica = 333333.333333 + pomylka;
- // metoda prostokatow
- for (int j = 0; j < liczbaM; j++)
- {
- int liczbaN = rnd.Next(10, 100000);
- double dx, calka_p, wysokosc_p = 0 , calka_t, wartosc_a = 0 , wartosc_b = 0;
- dx = liczbaN / (double)10000;
- calka_p = 0;
- for (double i = 0; i <= 100; i += dx)
- {
- wysokosc_p = i * i;
- calka_p += wysokosc_p * dx;
- }
- calka_p += wysokosc_p * dx;
- if (calka_p >= dolnaGranica && calka_p <= gornaGranica)
- {
- listBox1.Items.Add(calka_p.ToString());
- }
- calka_t = 0;
- for (double i = 0; i <= 100; i += dx)
- {
- wartosc_b = i * i;
- calka_t += ((wartosc_a + wartosc_b) * dx) / (double)2;
- wartosc_a = wartosc_b;
- }
- calka_t += wysokosc_p * dx;
- // if (calka_t >= dolnaGranica && calka_t <= gornaGranica)
- // {
- listBox2.Items.Add(calka_t.ToString());
- // }
- // listBox2.Items.Add(dx.ToString());
- }
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- }
- }
- ////////// model cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Zadania1z1
- {
- public enum AreaType
- {
- Rectangle,
- Trapezoid
- }
- public class SingleCount
- {
- public double X1 { get; set; }
- public double X2 { get; set; }
- public int N { get; set; }
- public AreaType AreaType { get; set; }
- public double Area { get; set; }
- public int CalculationNumber { get; set; }
- public int LowestN { get; set; }
- public double MinSquareError { get; set; }
- public SingleCount() { }
- public SingleCount(double x1, double x2, int n, AreaType areaType, double area, int calculationNumber)
- {
- this.X1 = x1;
- this.X2 = x2;
- this.N = n;
- this.AreaType = areaType;
- this.Area = area;
- this.CalculationNumber = calculationNumber;
- }
- public SingleCount(double x1, double x2, int n, AreaType areaType, double area, int calculationNumber, int lowestN)
- {
- this.X1 = x1;
- this.X2 = x2;
- this.N = n;
- this.AreaType = areaType;
- this.Area = area;
- this.CalculationNumber = calculationNumber;
- this.LowestN = lowestN;
- }
- }
- public class Global
- {
- public List<SingleCount> ListOfSingleCounts { get; set; }
- public Global() { }
- public Global(List<SingleCount> listOfSingleCounts)
- {
- this.ListOfSingleCounts = listOfSingleCounts;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement