Using C, how can I generate a random point on the complex plain?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
As a decent starting point, you could use
rand(). To generate a random number between -2 and +2, you can do:If you repeat this process, you can get an
xand ay:Now just use
xandyas your complex number.Also, be sure to call
srand()once (and only once) at the start of your program to seed the random number generator.