i have to do this assigment by the next monday...;)

i need to develop a test bank so i have to generate :

1-100 arrays of size 10 with randomly distinct numbers from (0-9)

2-100 arrays of size 50 with randomly distinct numbers from (0-49)

3-100 arrays of size 100 with randomly distinct numbers from (0-99)

4-100 arrays of size 200 with randomly distinct numbers from (0-199)

can u please help in the generation of these arrays..!

i used this code for the generation of the 100 arrays of size 10 but still i have problems in making the numbers distinct and limiting them in the required range for each size..can u help with that please:-| !

#include<iostream.h>

#include<cstdlib>

void main()

{ for(int i=0;i<=100;i++)

{

int a[10];

for (int j=0;j<=10;j++)

{ a[j]=rand()%10;

cout<<a[j];}

}}

## Recommended Answers

Jump to PostFirst you need to learn how to properly format your program -- that is one of the sloppiest format methods I've seen in a long time. Here is an example Notice that you should use spaces very plentifully to make your program easier to read. Curly braces go on a …

Jump to PostAn Argent problem, that's a new one ;)

Perhaps this 'argent' is what you meant.

http://www.catb.org/~esr/faqs/smart-questions.html#urgent

Jump to Postu could

`std::set<int> unique_ints ; // N == number of elements // MAX_VALUE == max value of an element while( unique_ints.size() < N ) unique_ints.insert( std::rand()%MAX_VALUE ) ; //iterate from unique_ints.begin() to // unique_ints.end() and populate the array`

Jump to Postfor your specific problem:

1-100 arrays of size 10 with randomly distinct numbers from (0-9)

2-100 arrays of size 50 with randomly distinct numbers from (0-49)

3-100 arrays of size 100 with randomly distinct numbers from (0-99)

4-100 arrays of size 200 with randomly distinct numbers from (0-199)u …

## All 16 Replies

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.