jiaying Posted September 15, 2009 Share Posted September 15, 2009 Hi, I was given a normal lab question and I have difficulty in understand and doing it. The question is: And lastly I was given the sample codes to start off. All I know is that I need to put this codes. #define RAND(X) ((double) rand()/RAND_MAX * X) Any help? Thanks! Link to comment Share on other sites More sharing options...
0 Argote Posted September 15, 2009 Share Posted September 15, 2009 You need to get a bunch of random coordinates and measure the euclidean distance [ sqrt ( (Xpoint - Xcenter)^2 + (Ypoint - Ycenter)^2) ) ] from that point to the center of the square, if it is greater than r then it's outside the circle, keep a count of the total attempts ( N ) and the ones that have been inside ( C ) and there you go. Link to comment Share on other sites More sharing options...
Question
jiaying
Hi, I was given a normal lab question and I have difficulty in understand and doing it. The question is:
And lastly I was given the sample codes to start off.
All I know is that I need to put this codes.
Any help?
Thanks!
Link to comment
Share on other sites
1 answer to this question
Recommended Posts