chinh nguyen

chinh nguyen

  • NA
  • 11
  • 0

help me

Jan 27 2009 8:41 PM
i'm doing my work about "find X element in N random element"
i have the code.
private void chia1()
            {
                Random rand = new Random();
                for (i = 0; i < cl.n / 100; i++)
                {
                    m[i] = rand.Next(99);
                    textBox1.Text += "" + m[i].ToString();
                    cl.m1[i] = m[i];
                }
            }
            private void chia2()
            {
                Random rand = new Random();
                for (i = cl.n / 100; i < 20 * cl.n / 100; i++)
                {
                    m[i] = rand.Next(99);
                    textBox3.Text += "" + m[i].ToString();
                    cl.m1[i] = m[i];
                }
            }
            private void chia3()
            {
                Random rand = new Random();
                for (i = 20 * cl.n / 100; i < 30 * cl.n / 100; i++)
                {
                    m[i] = rand.Next(99);
                    textBox5.Text += "" + m[i].ToString();
                    cl.m1[i] = m[i];
                }
            }
            private void chia4()
            {
                Random rand = new Random();
                for (i = 30 * cl.n / 100; i < 40 * cl.n / 100; i++)
                {
                    m[i] = rand.Next(99);
                    textBox6.Text += "" + m[i].ToString();
                    cl.m1[i] = m[i];
                }
            }
            private void chia5()
            {
                Random rand = new Random();
                for (i = 40 * cl.n / 100; i < 50 * cl.n / 100; i++)
                {
                    m[i] = rand.Next(99);
                    textBox7.Text += "" + m[i].ToString();
                    cl.m1[i] = m[i];
                }
            }
            private void chia6()
            {
                Random rand = new Random();
                for (i = 50 * cl.n / 100; i < 60 * cl.n / 100; i++)
                {
                    m[i] = rand.Next(99);
                    textBox8.Text += "" + m[i].ToString();
                    cl.m1[i] = m[i];
                }
            }
            private void chia7()
            {
                Random rand = new Random();
                for (i = 60 * cl.n / 100; i < 70 * cl.n / 100; i++)
                {
                    m[i] = rand.Next(99);
                    textBox9.Text += "" + m[i].ToString();
                    cl.m1[i] = m[i];
                }
            }
            private void chia8()
            {
                Random rand = new Random();
                for (i = 70 * cl.n / 100; i < 80 * cl.n / 100; i++)
                {
                    m[i] = rand.Next(99);
                    textBox10.Text += "" + m[i].ToString();
                    cl.m1[i] = m[i];
                }
            }
            private void chia9()
            {
                Random rand = new Random();
                for (i = 80 * cl.n / 100; i < 90 * cl.n / 100; i++)
                {
                    m[i] = rand.Next(99);
                    textBox11.Text += "" + m[i].ToString();
                    cl.m1[i] = m[i];
                }
            }
            private void chia10()
            {
                Random rand = new Random();
                for (i = 90 * cl.n / 100; i < cl.n; i++)
                {
                    m[i] = rand.Next(99);
                    textBox12.Text += "" + m[i].ToString();
                    cl.m1[i] = m[i];
                }
            }

can you help me optimize it.
thanks.

Answers (4)