AnonymousEng

The Circle :)

Jan 14th, 2013
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. C     R is the raduis of the circle y^2 + X^2 = R
  2.       R = sqrt(4.0)
  3. C     num is the number of points (i,j) that i and j are integers :)
  4. C     and is in the boundary of the circle
  5.       num = 0.0
  6.      
  7. C     we made two loops too scan all the points of the (first quarter)
  8. C     including the (0,1) (0,2) and
  9. C     points are (in this example) : (1,1),(1,2),(2,1),(2,2)
  10. C     cuz we put the maximum is 2 = R  ^_^
  11.       do 10 i=0,R
  12.          do 20 j=1,R
  13. C     instR (is the raduis of the current point) we will use the radius
  14. C     to compare if the point is in the circle or not ^_^
  15.             instR = ((i**2) + (j**2) )**(0.5)
  16.             if(instR.LT.R) num = num + 1
  17.  20      continue
  18.  10   continue
  19.  
  20. C     here we multiplied the number * 4  , cuz we have 4 quarters and we
  21.       totalN = (4 * num)+1
  22.       write (*,*)totalN
  23.      
  24.       pause
  25.       stop
  26.       end
Advertisement
Add Comment
Please, Sign In to add comment