Is there a way to get random numbers from the C++ srand() method in Java?
-
I am trying to make a Java implementation of the Microsoft FreeCell card game and this means I need to generate the order of the deck using exactly the same method that Microsoft ...show more
-
Answer:
Java has JNI and JNA. JNI is Java Native Interface. You write wrappers for the C++ functions you want to expose to Java. JNA is the same thing, except the coding for the C++ wrappers is linked as a 'lazy' reference.
L4NKOYVSJZZFR4D65GZ3BWLUPM at Yahoo! Answers Visit the source
Other answers
Java has ways of getting random numbers 1) There's the method in the Math class random(). 2) There's also a Random class. Since rand() returns ints and you usually use % to get the range that you want, you'll probably want to define a Random object import java.util.Random; Random rand = new Random(); to get and int between 0 and k-1: int val = rand.nextInt(k);
modulo_function
For crying out loud, doesn't Java have a random number function?
ok_ranger
i don't see why you don't just use java's method of generating numbers, whatever that is, it should be the same algorithm, or almost the same as the random number is based on the current time on your computer
Matias
Related Q & A:
- Is there a way to get an old account back?Best solution by Yahoo! Answers
- Is there a way to get work on Yahoo?Best solution by Yahoo! Answers
- Is there a way to get rid of these?
- Is there a way to get my yahoo e-mail on mail.app for free?Best solution by Yahoo! Answers
- Is there a way to get skype messenger on mobile web without downloading anything?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.