Advertisement
Guest User

Untitled

a guest
Oct 17th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  2. Graph1 = Me.PictureBox1.CreateGraphics()
  3. Graph1.Clear(Color.White)
  4. N = Val(TextBox1.Text)
  5. R = Val(TextBox2.Text)
  6. Graph1.TranslateTransform(100, 100)
  7. Graph1.DrawEllipse(Pen1, -R, -R, 2 * R, 2 * R)
  8. Graph1.DrawRectangle(Pen1, -R, -R, 2 * R, 2 * R)
  9. For I = 1 To N
  10. X = Int(Rnd() * 2 * R) - R
  11. Y = Int(Rnd() * 2 * R) - R
  12. Graph1.DrawEllipse(Pen1, X, Y, 1, 1)
  13. If X ^ 2 + Y ^ 2 <= R ^ 2 Then M = M + 1
  14. Next I
  15. Label1.Text = 4 * (M / N) * (R ^ 2)
  16. Label2.Text = 4 * (M / N)
  17. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement