سلام
توی جاوا یا اندروید چطوری اعداد تصادفی میشه ساخت؟
مثلا توی سی شارپ اینجوریه>
[CSHARP]
Random rnd = new Random();
rnd.Next(); // ya rnd.Next(1,1000000);
[/CSHARP]
0
سلام
یه تابع برای تولید اعداد تصادفی:
public static int randInt(int min, int max) {
// NOTE: Usually this should be a field rather than a method
// variable so that it is not re-seeded every call.
Random rand = new Random();
// nextInt is normally exclusive of the top value,
// so add 1 to make it inclusive
int randomNum = rand.nextInt((max - min) + 1) + min;
return randomNum;
}
سوال برنامه نویسی دارید؟
ندونستن عیب نیست، نپرسیدن چرا!