# include & ltstdlib.h & gt
# include & ltstring.h & gt
# include & lttime.h & gt
void selectsort(int *x,int n) {
int i,j,min,t;
for(I = 0;我& ltn-1;i++) {
min = I;
for(j = I+1;j & ltn;j++) {
if(*(x+j)& lt;*(x+min))min = j;
}
如果(min!= i) {
t = *(x+I);
*(x+I)= *(x+min);
*(x+min)= t;
}
}
}
void select(int m,int n,int k) {
int num[36],tmp[36],t;
char filename[]= " c:\ \ 2011 \ \隨機數。txt ";//選擇妳需要的路徑。
FILE * fp
srand((無符號)時間(空));
fp = fopen(文件名,“wt”);
if(fp == NULL) {
Printf("打開文件%s時出錯,\n ",文件名);
退出(1);
}
for(int I = 0;我& ltk;++i) {
for(int j = 1;j & lt= m;++ j)tmp[j]= j;
for(j = 0;j & ltn;++j) {
t =(無符號)rand()% m+1;
if(tmp[t]!= 0) {
num[j]= t;
tmp[t]= 0;
}
else-j;
}
selectsort(num,n);
for(j = 0;j & ltn;++j) {
fprintf(fp," %02d ",num[j]);
printf("%02d ",num[j]);
}
fprintf(fp," \ n ");
printf(" \ n ");
}
fclose(FP);
}
int main() {
int m,n,k;
Printf("所選數字個數:");
scanf("%d ",& ampm);
Printf("可選數字個數:");
scanf("%d ",& ampn);
Printf("所選組數:");
scanf("%d ",& ampk);
select(m,n,k);
返回0;
}