#P1157. 组合的输出
组合的输出
Description
Permutation and combination are common mathematical methods. A combination means selecting elements from elements (order does not matter and ). We can simply think of the elements as the natural numbers , and choose any numbers from them.
You are required to output all combinations.
For example, when , all combinations are:
.
Input Format
A single line with two natural numbers (, ).
Output Format
Output all combinations. Each combination occupies one line, and the elements in it are sorted in ascending order. Each element occupies a field width of three characters. All combinations are in lexicographical order.
Note: When outputting, each number must have a field width of . In C++, you can use the following code:
cout << setw(3) << x;
This outputs a number with a field width of . Note that you need the header file iomanip.
5 3
1 2 3
1 2 4
1 2 5
1 3 4
1 3 5
1 4 5
2 3 4
2 3 5
2 4 5
3 4 5
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号