Problem E: 组合的输出

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:154 Solved:100

Description

排列与组合是常用的数学方法,其中组合就是从 n 个元素中抽出 r 个元素(不分顺序且 r<=n),
我们可以简单地将 n 个元素理解为自然数 1,2,…,n,从中任取 r 个数。
现要求你用递归的方法输出所有组合。

Input

一行两个自然数 n、r(1<n<21,1<=r<=n)。

Output

所有的组合,每一个组合占一行且其中的元素按由小到大的顺序排列,每个元素占三个字符的位置,所
有的组合也按字典顺序。

Sample Input Copy

5 3

Sample Output Copy

  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