The random function, generates the same values each the time program is run.. Any other function to output random numbers, each time the program is run ??
Master Mascus
0
Light Poster
Recommended Answers
Jump to PostThe usual method is seeding rand() with the current time:
#include <stdio.h> #include <stdlib.h> #include <time.h> int main(void) { int i; srand((unsigned)time(NULL)); for (i = 0; i < 10; i++) printf("%3d", rand() % 100); putchar('\n'); return 0; }
Jump to Postno there are no such restrictions
Jump to Postbut if i need to apply that in my work, how can i do it ??
Generate the numbers, then shuffle them randomly. For example, see this thread, or this thread.
Jump to Posthowever if all the numbers are not in the requirements random shuffle wont work.
If the above threads dont solve your problem,you would need to go for finding duplicates and there are several algorithms to do that.All depends on the application of the code,as complexity of the algorithms makes them …
Jump to Posthowever if all the numbers are not in the requirements random shuffle wont work.
Your use of the word "requirements" is confusing. Can you elaborate?
All 18 Replies
Narue
5,707
Bad Cop
Team Colleague
Master Mascus
0
Light Poster
arghasen
0
Light Poster
Master Mascus
0
Light Poster
Narue
5,707
Bad Cop
Team Colleague
arghasen
0
Light Poster
Narue
5,707
Bad Cop
Team Colleague
Master Mascus
0
Light Poster
arghasen
0
Light Poster
Narue
5,707
Bad Cop
Team Colleague
Master Mascus
0
Light Poster
Narue
5,707
Bad Cop
Team Colleague
Master Mascus
0
Light Poster
Narue
5,707
Bad Cop
Team Colleague
ashok1514
-4
Newbie Poster
Narue
5,707
Bad Cop
Team Colleague
Master Mascus
0
Light Poster
Narue
5,707
Bad Cop
Team Colleague
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.