Lotto-1996/97 Ulm internal contest

Source: Internet
Author: User

In the German lotto you have to select 6 numbers from the set {1, 2 ,..., 49 }. A popular strategy to play lotto-although it doesn' t increase your chance of winning-is to select a subset S containingK(K> 6) of these 49 numbers, and then play several games with choosing numbers only from s. For example,K= 8 and S = {,} There are 28 possible games, 3, 5, 8, 34], [1, 2, 3, 5, 13, 21],... [,].

Your job is to write a program that reads in the numberKAnd the set S and then prints all possible games choosing numbers only from S.

Input

The input file will contain in one or more test cases. Each test case consists of one line containing several integers separated from each other by spaces. The first integer on the line will be the numberK(6 K integers, specifying the set S, will follow in ascending order. input will be terminated by a value of zero (0)K.
Output

For each test case, print all possible games, each game on one line. the numbers of each game have to be sorted in ascending order and separated from each other by exactly one space. the games themselves have to be sorted lexicographically, that means sorted by the lowest number first, then by the second lowest and so on, as demonstrated in the sample output below. the test cases have to be separated from each other by exactly one blank line. do not put a blank line after the last test case.
Sample Input

7 1 2 3 4 5 6 78 1 2 3 5 8 13 21 340
Sample output
1 2 3 4 5 61 2 3 4 5 71 2 3 4 6 71 2 3 5 6 71 2 4 5 6 71 3 4 5 6 72 3 4 5 6 71 2 3 5 8 131 2 3 5 8 211 2 3 5 8 341 2 3 5 13 211 2 3 5 13 341 2 3 5 21 341 2 3 8 13 211 2 3 8 13 341 2 3 8 21 341 2 3 13 21 341 2 5 8 13 211 2 5 8 13 341 2 5 8 21 341 2 5 13 21 341 2 8 13 21 341 3 5 8 13 211 3 5 8 13 341 3 5 8 21 341 3 5 13 21 341 3 8 13 21 341 5 8 13 21 342 3 5 8 13 212 3 5 8 13 342 3 5 8 21 342 3 5 13 21 342 3 8 13 21 342 5 8 13 21 343 5 8 13 21 34
My code has been AC

# Include
Static int I, K, start, s [50], i1, I2, I3, I4, I5, I6, O;

Int main ()

{

While (scanf ("% d", & K )! =-1 ){

If (K! = 0 ){

If (o) {printf ("/N ");}

Else {o = 1 ;}

}

Else

Break;

For (I = 1; I for (I1 = 1; I1 for (I2 = I1 + 1; I2 for (I3 = I2 + 1; I3 for (I4 = I3 + 1; i4 for (I5 = I4 + 1; I5 for (I6 = I5 + 1; I6 printf ("% d/N ", s [I1], s [I2], s [I3], s [I4], s [I5], s [I6]);}

Return 0;

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.