-4

Given a set of consecutive numbers S1 i.e [1,2,3,4,5,6,7,8,...N1].Also a small set S2 of consecutive numbers i.e [1,2,3,4,5,6....N2]. N2<< N1

Now starting from first element i.e S2[i](i: 1 to N2) of set S2, you have to pick S2[i] consecutive RANDOM numbers from S1. Once you pick any number from S1,in any i(th) turn you can't pick it anymore in any other turn.

So my main goal is learn 'How To pick RANDOM numbers in such way'.This question is not part of any Coding Competition, or Homework. It is only for learning purpose.

If possible please use C language,as i am beginner in programming.

Jay Patel
  • 505
  • 6
  • 10
  • did you google for 'c random number' . I did. First hit http://stackoverflow.com/questions/822323/how-to-generate-a-random-number-in-c – pm100 Nov 18 '16 at 18:42
  • 1
    SO is meant for answering specific programming questions, not general ones. One clue that your question is off-topic is that you haven't even included any code. Please thoroughly read [the help pages](http://stackoverflow.com/help) - in particular, ["What topics can I ask about here?"](http://stackoverflow.com/help/on-topic), ["What types of questions should I avoid asking?"](http://stackoverflow.com/help/dont-ask), ["How do I ask a good question?"](http://stackoverflow.com/help/how-to-ask) and ["How to create a Minimal, Complete, and Verifiable example"](http://stackoverflow.com/help/mcve). – Random Davis Nov 18 '16 at 18:42
  • Please start with a program that generates random numbers. Then restrict the range to the indexed length of an array. Then step by tiny step ... – Weather Vane Nov 18 '16 at 18:50
  • 1
    I'm voting to close this question as off-topic because it's asks us to do the poster's work for him. – Steve Summit Nov 18 '16 at 19:11

1 Answers1

1

Use rand() function defined in C standard Library, and make an array of length in which you have to produce random number. Then on getting the particular number, simply put a value 1 in the particular array space. Again if you get same random number where the value is 1 in the array then start random function again so as to get a new random element.

Swr7der
  • 849
  • 9
  • 28