943,843 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Marked Solved
  • Views: 1369
  • C RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Jun 9th, 2009
2

Re: How can i more control rand()

>As I can say "Build an operating system." is a single step
It is, but you have to increase the granularity of your steps to come up with reasonable milestones. I find it somewhat humorous that you compare building an operating system to a trivial twenty line homework program.

>My recent interaction with low level languages are responsible for this.
That's a bad thing. Even at the lowest level you still need to keep an abstract view of your design.
Last edited by Narue; Jun 9th, 2009 at 11:15 am.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Jun 9th, 2009
1

Re: How can i more control rand()

A day ago csurfer's algorithm solved the problem. That's "pipelined" version:
  1. int i, j = rand()%20;
  2. for (i = 0; i < 20; i++)
  3. array[i] = (i != j)*(rand()%9 + 1);
In addition: it's impossible to add another level of randomness by random shuffles or other tricks while we are using the same (extremely bad ) rand() generator.
Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008
Jun 9th, 2009
0

Re: How can i more control rand()

>I find it somewhat humorous that you compare building an operating system to a
>trivial twenty line homework program.
Then my purpose was solved.

>That's a bad thing. Even at the lowest level you still need to keep an abstract
>view of your design.
The program I was interacting with were very trivial ( prime number generator ). It was in a algorithm book. There, the author used a ASM, to demonstrate that what a high-level program assumes to be `a step' is actually a series of steps in machine code.
But you said it right, one should be able to `quantize' a step. It also varies from person to person and to which domain he is working.

>it's impossible to add another level of randomness by random shuffles or other
>tricks while we are using the same (extremely bad ) rand() generator.
She assumed a perfect random generator while making that remark, IMHO. And she was right too. More random calls will tend to dilate the variance. (of course, I am too, making this remark assuming a perfect random generator)
Reputation Points: 1486
Solved Threads: 140
Practically a Posting Shark
siddhant3s is offline Offline
816 posts
since Oct 2007
Jun 9th, 2009
0

Re: How can i more control rand()

^ so.... whatever happened to June 6th?
Reputation Points: 2143
Solved Threads: 178
Posting Maven
jephthah is offline Offline
2,567 posts
since Feb 2008
Jun 9th, 2009
0

Re: How can i more control rand()

>^ so.... whatever happened to June 6th?
The plan stretched. Didn't bother to change the signature. (I know this is ignorance). Long story!!...
Reputation Points: 1486
Solved Threads: 140
Practically a Posting Shark
siddhant3s is offline Offline
816 posts
since Oct 2007
Jun 10th, 2009
0

Re: How can i more control rand()

Quote ...
Long story!!
yeah, it usually is, when you try and quit the internets.
Reputation Points: 2143
Solved Threads: 178
Posting Maven
jephthah is offline Offline
2,567 posts
since Feb 2008
Jun 10th, 2009
0

Re: How can i more control rand()

>More random calls will tend to dilate the variance.
The variance of... what? We didn't estimate random sequence parameters in that case so the variance (or other moments) does not bear a relation to the sequence of 20 random numbers.
Reputation Points: 1234
Solved Threads: 347
Postaholic
ArkM is offline Offline
2,001 posts
since Jul 2008
Jun 12th, 2009
0

Re: How can i more control rand()

Thanks you guys for all your suggestions i solve the problem ^^
Reputation Points: 3
Solved Threads: 0
Newbie Poster
animefun2 is offline Offline
17 posts
since Jul 2008
Jun 12th, 2009
0

Re: How can i more control rand()

After filling the array make a loop to check whether there is any element with zero value
If not then fill it again if it is then break
Reputation Points: 18
Solved Threads: 1
Newbie Poster
seemant_sun is offline Offline
13 posts
since May 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

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: Array question
Next Thread in C Forum Timeline: fgets





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


Follow us on Twitter


© 2011 DaniWeb® LLC