944,026 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1779
  • C RSS
Feb 17th, 2006
0

help me on my case study!!!

Expand Post »
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...
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tomoyo_13m is offline Offline
3 posts
since Feb 2006
Feb 17th, 2006
4

Re: help me on my case study!!!

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.
Team Colleague
Reputation Points: 1135
Solved Threads: 172
Super Senior Demiposter
Rashakil Fol is offline Offline
2,479 posts
since Jun 2005
Feb 17th, 2006
0

Re: help me on my case study!!!

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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
tomoyo_13m is offline Offline
3 posts
since Feb 2006
Feb 17th, 2006
0

Re: help me on my case study!!!

Quote 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:
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Audio measurement dll using sound card?
Next Thread in C Forum Timeline: conversions to int/double/etc...





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC