Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
- Graph1 = Me.PictureBox1.CreateGraphics()
- Graph1.Clear(Color.White)
- N = Val(TextBox1.Text)
- R = Val(TextBox2.Text)
- Graph1.TranslateTransform(100, 100)
- Graph1.DrawEllipse(Pen1, -R, -R, 2 * R, 2 * R)
- Graph1.DrawRectangle(Pen1, -R, -R, 2 * R, 2 * R)
- For I = 1 To N
- X = Int(Rnd() * 2 * R) - R
- Y = Int(Rnd() * 2 * R) - R
- Graph1.DrawEllipse(Pen1, X, Y, 1, 1)
- If X ^ 2 + Y ^ 2 <= R ^ 2 Then M = M + 1
- Next I
- Label1.Text = 4 * (M / N) * (R ^ 2)
- Label2.Text = 4 * (M / N)
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement