help me on my case study!!!

Reply

Join Date: Feb 2006
Posts: 3
Reputation: tomoyo_13m is an unknown quantity at this point 
Solved Threads: 0
tomoyo_13m tomoyo_13m is offline Offline
Newbie Poster

help me on my case study!!!

 
0
  #1
Feb 17th, 2006
i have a case study....
my prof said that we should display 10 random numbers without repeating the same number for example the screen will print numbers from 0-9 at this order

1 6 7 5 2 3 4 9 8 0

then when we exit the program it should print another random number... plss help i needed it very badly :cry: :cry: :cry:

tanx...
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 2,002
Reputation: Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice Rashakil Fol is just really nice 
Solved Threads: 137
Team Colleague
Rashakil Fol's Avatar
Rashakil Fol Rashakil Fol is offline Offline
Super Senior Demiposter

Re: help me on my case study!!!

 
0
  #2
Feb 17th, 2006
I don't see why you would need any help, so how can I know how to help you? You could be a bit more specific about where you're having problems.
All my posts may be redistributed under the GNU Free Documentation License.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 3
Reputation: tomoyo_13m is an unknown quantity at this point 
Solved Threads: 0
tomoyo_13m tomoyo_13m is offline Offline
Newbie Poster

Re: help me on my case study!!!

 
0
  #3
Feb 17th, 2006
ahm... my idea is having a 3 for loop the first loop will generate the 10 random numbers from 0-9 and the second loop will check if the number that was generated before is already in the array and it will check if the it is the last in the array,if it generate the second number and compare it to the first number and it check that it is the same it will generate again...i need a counter in this program but i dont know hoe to do the second loop im thingking of doing a while loop instead of for loop
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 376
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: help me on my case study!!!

 
0
  #4
Feb 17th, 2006
Originally Posted by tomoyo_13m
ahm... my idea is having a 3 for loop the first loop will generate the 10 random numbers from 0-9 and the second loop will check if the number that was generated before is already in the array and it will check if the it is the last in the array,if it generate the second number and compare it to the first number and it check that it is the same it will generate again...i need a counter in this program but i dont know hoe to do the second loop im thingking of doing a while loop instead of for loop
Create an array holding the numbers 0-9

int array[]= {0,1,2,3,4,5,6,7,8,9}

Then randomly pick two index values and swap their contents.
Keep going until the array is sufficiently randomised, then print out the solution.

And this is the exact procedure used for deck shuffling programs to avoid rolling out a repeat. :rolleyes:
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC