document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. #include<iostream>
  2. using namespace std;
  3. #include <algorithm>
  4. int n,m;
  5. int num[100];
  6. int output[100];
  7.  
  8. void comb(int nowIndex, int addIndex);
  9.  
  10. int main()
  11. {
  12.  
  13.  
  14. while(cin>>n)
  15. {
  16. if(n==0)
  17. {
  18. break;
  19. }
  20.  
  21. for(int i=0;i<n;i++)
  22. {
  23. cin>>num[i];
  24. }
  25. sort(num,num+n);
  26.  
  27. cin>>m;
  28.  
  29. comb(0,-1);
  30.  
  31. cout<<endl;
  32. }
  33.  
  34.  
  35. return 0;
  36. }
  37.  
  38.  
  39. void comb(int nowIndex, int addIndex)
  40. {
  41. if(nowIndex==m)
  42. {
  43. for(int i=0;i<m;i++)
  44. {
  45. cout<<output[i]<<" ";
  46. }
  47. cout<<endl;
  48. }
  49. else
  50. {
  51. for(int i=addIndex+1;i<n;i++)
  52. {
  53. output[nowIndex]=num[i];
  54. comb(nowIndex+1,i);
  55. }
  56. }
  57. }
');