您的答案為: 5 9 正確答案為: 199 9991
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n;
int x[150];
int i, j;
int group;
int mo, co, th;
while(cin >> n){
if(n == 0)
break;
for(i = 0; i<n; i++)
cin >> x[i];
sort(x, x + n);
cin >> group;
int pos[group];
for(i = 0; i<group; i++)
pos[i] = i;
mo = n - group ; co = 0; th = group - 2;
while(pos[0] <= n - group){
while(pos[group - 1] < n){
cout << x[pos[0]];
for(i = 1; i<group; i++)
cout << " " << x[pos[i]];
cout << endl;
pos[group - 1]++;
}
pos[th] ++;
co ++;
for(j = th; j < group; j++)
pos[j+1] = pos[j]+1;
if(co == mo){
co = 0; th--;}
}
cout << endl;
}
}