Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Windows.Forms;
- public partial class Form1 : Form
- {
- private int size;
- private int pop;
- //private int k;
- private List<double> p = new List<double>();
- private List<double> m = new List<double>();
- private int counter;
- public Form1()
- {
- InitializeComponent();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- pop = int.Parse(textBox1.Text);
- size = int.Parse(textBox3.Text);
- textBox1.ReadOnly = true;
- textBox3.ReadOnly = true;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- if (counter < pop)
- {
- p.Add(double.Parse(textBox2.Text));
- textBox2.Text = "";
- counter++;
- if (counter == pop)
- {
- textBox2.ReadOnly = true;
- button1.Hide();
- }
- }
- }
- private void button2_Click(object sender, EventArgs e)
- {
- lessCombo(p, 0, 0, 0);
- string str = "";
- str += "Mean - Relative Frequency\n";
- if (m.Count > 100)
- {
- double[] array = new double[100];
- for (int b = 0; b < array.Length; b++)
- {
- array[b] = m[b];
- }
- foreach (var group in array.GroupBy(n => n))
- {
- str += string.Format("{0} - {1} \n", group.Key, group.Count());
- }
- }
- else
- {
- foreach (var group in m.GroupBy(n => n))
- {
- str += string.Format("{0} - {1} \n", group.Key, group.Count());
- }
- }
- richTextBox1.Text = str;
- button2.Hide();
- }
- private void lessCombo(List<double> p, int i, int l, double a)
- {
- if (l == size)
- {
- double mean = a / size;
- m.Add(mean);
- }
- if (i < p.Count)
- {
- if (l != size)
- {
- lessCombo(p, i + 1, l + 1, a + p[i]);
- lessCombo(p, i + 1, l, a);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement