Computer Science Canada Help with random number program |
Author: | JR [ Tue Feb 03, 2004 5:15 pm ] | ||
Post subject: | Help with random number program | ||
hey, i'm new to the site. i got a problem with a program, i need to to make 10 random numbers but with one program. thats what i got for now.
any tips? |
Author: | santabruzer [ Tue Feb 03, 2004 5:22 pm ] | ||
Post subject: | |||
here's your prog.. just a abit changed.. i say for statement is better.. but just continuing what you did:
|
Author: | JR [ Tue Feb 03, 2004 5:28 pm ] |
Post subject: | |
k thx alot |
Author: | Cervantes [ Tue Feb 03, 2004 5:35 pm ] | ||||||||
Post subject: | |||||||||
for clarification and cleaning things up.
is the same as
also you don't need to have randint twice inside the loop, get rid of the lower one. also, though this works
it saves you code to just put
|
Author: | JR [ Tue Feb 03, 2004 5:51 pm ] | ||
Post subject: | |||
bah im such a noob in turing. i got another question. i made this program
now i figured out how to do 100 dice rolls, my problem is how do i set how many vars of each number where used? like if there was 20 1's 20 2's ect how do i find how many 1-6 there was? |
Author: | Cervantes [ Tue Feb 03, 2004 6:09 pm ] | ||
Post subject: | |||
you could use an array to make 100 vars, but you don't need to do that use a for statement.. santa mentioned them earlier. var howmany : int put "How many times would you like to roll the dice? : " .. get howmany
that's only for rolling 1 die though.. you can alter that prog so that you can roll 2 dies and add them together and determine how many of what you get. |
Author: | Andy [ Tue Feb 03, 2004 8:32 pm ] |
Post subject: | |
y dont u have arrays? just go dice(Rand.Int(1,6))+=1 |
Author: | santabruzer [ Tue Feb 03, 2004 8:40 pm ] | ||
Post subject: | |||
*whistles*...
|
Author: | Thuged_Out_G [ Wed Feb 04, 2004 8:41 pm ] |
Post subject: | |
dammit, i never even thought of that...i did the same program...but i used 6 different for loops i think...ill post the method i did later on so you can all laugh at it ![]() |