Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / random number from 10000001 - 50000001

Author
Message
Ghost Games
18
Years of Service
User Offline
Joined: 1st Aug 2007
Location:
Posted: 11th Jun 2010 10:13
hi

is it possible to get darkbasic to output 100 diffrent numbers to the screen, between 10000001-50000001 and list them with the higest number first, and the lowest number is in the bottom.

cant get it to ork probberly self.


Thx.
Sven B
21
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 11th Jun 2010 11:28 Edited at: 11th Jun 2010 11:29
Sure, to get a random number in that range you need to use
nr = 10000001 + rnd(50000001 - 10000001)

Save them in an array of 100 elements and then sort that array with a sorting algorithm (straight selection sort, straight insertion sort, quicksort, bubble sort, ... I suggest searching the internet). Or if you don't need to sort it, you can just search for the biggest number each time, eg in pseudocode



Cheers!
Sven B

sladeiw
17
Years of Service
User Offline
Joined: 16th May 2009
Location: UK
Posted: 11th Jun 2010 14:25
If you prefer a shortcut for sorting an array, the matrix1 utils has various array sorting methods. Simple as `sort array arrayname()`

Login to post a reply

Server time is: 2026-07-25 16:21:11
Your offset time is: 2026-07-25 16:21:11