Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 help counting numbers plz
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
EndingPeace




PostPosted: 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
Sponsor
sponsor
Unforgiven




PostPosted: Thu Dec 11, 2008 10:27 am   Post subject: RE:help counting numbers plz

Well, what part did you need help with?
Tony




PostPosted: 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.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Parker




PostPosted: 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




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: