Home > Back-end >  Curriculum design data structure (C language)
Curriculum design data structure (C language)

Time:01-07

Build a lottery selection number set

CodePudding user response:

qq1163418353

CodePudding user response:

Lottery to select number problem: in the lottery market, more is a kind of "lotto games" lottery tickets, such as 9, 31, 37 to choose 7 and 21 5, etc., with "21 selected five" this type of lottery, for example, when buying tickets, choose five Numbers from 0 to 21, the arrangement of five Numbers constitute a set of Numbers, become "a note lottery", in after you choose a good number of such 5 arrangement, lottery ticket vending machine, can print out your choice of a note of lottery tickets, she will be in front of the unit digit zero padding, yes 5 Numbers are two Numbers, for example, if you select the,5,8,16,21 {2} the five Numbers, and put them in a discharge in the first to fifth from left to right, then choose one lottery ticket vending machine will print 10 digital sequence, as follows:
02 05 08 16 21
It is important to note that 05 02 08 21 16 ditto the sequence of Numbers, is not the same note lottery; And when choosing five Numbers, the five Numbers cannot be the same,
Now some professional punters, will buy lottery tickets as part of the daily, some professional punters, long-term buy lottery tickets, collected the tickets on sale since the issue of number, in these Numbers, they found that there are few two midterm will number the same situation, in the process of choosing number, they will also use some software to produce some arrangement for their favorite figures, considering that has been in the lottery number, they will put these filter, please put forward the solution, help them quickly from his beloved find has the set of Numbers arranged in lottery number, for convenience, assume that your favourite set of Numbers arranged in early will be of the number of the set A and B each note number, are made to A 10 string representation of the length of the figures, both the inside of the collection number produced by then, note the number number is not less than 5000,
[basic requirements]
(1) input data include: his favourite set of Numbers arranged A, pre-production and will be of the number of the set B, are stored in the input file input. TXT. Output set A and set B the same number in the string, and stored in the output. TXT,
(2) the collection of data in A and B, the number of strings with the method of pseudo random number generation, every note of the five data cannot be repeated,
(3) use a variety of comparison algorithm to achieve the same number of string search, at least use selection sort or bubble sort, quick sort or merge sort, heap sort, hill sorting) or number of statistics and comparison,
(4) in the process of number string comparison, cannot use the STRCMP () function, or the way the string class object, call a function to compare the efficiency will be lower, suggest to convert a string to basic data types, such as int or long,
(5) to prompt the way the menu that USES various sorting algorithms to compare two collection element,

CodePudding user response:

Is there any code
  • Related