All pastes #980561 Raw Edit

Anonymous

public text v1 · immutable
·published 2008-04-11 02:46 UTC
rendered paste body
private void button1_Click(object sender, EventArgs e)
        {
            int a = 0;
            int b = 0;
            int c = 0;
            int x = 0;
            int y = 0;
            int z = 0;
            int num = 0;

            Random RandomClass = new Random();
            RandomClass.Next(1, 4);

            for (num = 0; num <= 1000000; num++)
            {
                int tar = RandomClass.Next(1,4);   // The correct door
                int guess = RandomClass.Next(1,4); // The guessed first door
                int sho = tar;                     // Make sure we don't show the correct door
                while (sho == tar)
                    sho = RandomClass.Next(1,4);   // Show a incorrect door

                if ((guess == 1) && (sho == 2))    // Change the answer to the remaining door
                    guess = 3;
                if ((guess == 1) && (sho == 3))
                    guess = 2;
                if ((guess == 2) && (sho == 1))
                    guess = 3;
                if ((guess == 2) && (sho == 3))
                    guess = 1;
                if ((guess == 3) && (sho == 1))
                    guess = 2;
                if ((guess == 3) && (sho == 2))
                    guess = 1;

                if ((guess == 1) && (tar == 1))   // If we were right, let's note it in the proper bin...
                    a++;
                if ((guess == 2) && (tar == 2))
                    b++;
                if ((guess == 3) && (tar == 3))
                    c++;

                if (tar == 1)
                    x++;
                if (tar == 2)
                    y++;
                if (tar == 3)
                    z++;
            }
            MessageBox.Show("Out of 1000000 chances we got: " + ((int)a + b + c).ToString() + "\n" + a.ToString() + ":" + b.ToString() + ":" + c.ToString());
            MessageBox.Show("X: " + x.ToString());
            MessageBox.Show("Y: " + y.ToString());
            MessageBox.Show("Z: " + z.ToString());
        }