-->
当前位置:首页 > 题库

PROGRAMMING:Xiao Ming buys apples

Luz5年前 (2021-05-10)题库406
Xiaoming goes to the supermarket to buy apples. There are n apples in the supermarket, and each apple has a unique English alphabet. Xiaoming plans to choose several apples from all the apples to buy (or maybe none). Please write a program to help Xiaoming find out all the possible choices. Each method gives the label of each apple in dictionary order.
Dictionary order, that is, the order of strings in the dictionary. For two strings, the comparison starts from the first character. When the characters in a certain position are different, the dictionary order of the string with smaller characters in that position is smaller. For example, ABC is smaller than abd.
###Input format:
The input is a positive integer n, which means the number of apples in the supermarket. N does not exceed 15. The label of apple is a, B, C, D. If n = 1, apple is a; If n = 3, apple is a, B, C; If n = 4, apple is a, B, C, D; and so on.
###Output format:
Output for a number of lines of string, each line represents a pick Xiaoming. Each selection method should be included with {}, and the labels of each apple should be separated by commas in western language, such as {a, B, C}. The labels should be arranged in dictionary order“ Buy nothing "is the first choice to output, which is {}, with no space in the middle.
###Input example:
```in
three
```
###Output example:
```out
{}
{a}
{a,b}
{a,b,c}
{a,c}
{b}
{b,c}
{c}
```







answer:If there is no answer, please comment