help counting numbers plz
Author |
Message |
EndingPeace
|
Posted: Thu Dec 11, 2008 10:23 am Post subject: help counting numbers plz |
|
|
i need help with a program the gets 1000 from 0 to 25 random numbers and the counts how many of each is there.
i don't need help with the random number part but can i get some hints to the rest plz and thank you |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Unforgiven
|
Posted: Thu Dec 11, 2008 10:27 am Post subject: RE:help counting numbers plz |
|
|
Well, what part did you need help with? |
|
|
|
|
|
Tony
|
Posted: Thu Dec 11, 2008 10:52 am Post subject: RE:help counting numbers plz |
|
|
You will need a for-loop and an array of counters. |
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Parker
|
Posted: Thu Dec 11, 2008 5:09 pm Post subject: RE:help counting numbers plz |
|
|
Um, working on your grammar would make this easier to read but...
have something like
Turing: |
loop
randint(randomnum, 125)
total := total + randomnum
exit when total >= 1000
end loop |
|
|
|
|
|
|
Insectoid
|
Posted: Thu Dec 11, 2008 6:07 pm Post subject: RE:help counting numbers plz |
|
|
I believe the objective is 'create 1000 random numbers between 0 and 25 and count how many of each number (ie 1's, 2's, 3's, 4's, etc) there are'.
Don't use randint, it is annoying to see and Rand.Int is better. it works like code: | randNum := Rand.Int (0, 25) |
You will need an array 0..25 of int. Use a for loop that runs 1000 times (for x: 0..1000). Then generate a number using Rand.Int(). substitute it into the index of the array (<arrayName>(randNum) += 1), and you're done!
Parker, try not to give the answer. |
|
|
|
|
|
|
|