#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <time.h>
int
*d;
int
n,m,i,a,b,t;
int
main() {
srand
(
time
(NULL));
while
(1) {
printf
(
"Input n m(n>=m>0):"
);
fflush
(stdout);
rewind
(stdin);
if
(2==
scanf
(
"%d%d"
,&n,&m)) {
if
(n>=m && m>0)
break
;
}
}
d=(
int
*)
malloc
((n+1)*
sizeof
(
int
));
if
(NULL==d)
return
1;
for
(i=0;i<=n;i++) d[i]=i;
for
(i=n+1;i>0;i--) {
a=i-1;b=
rand
()%i;
if
(a!=b) {t=d[a];d[a]=d[b];d[b]=t;}
}
for
(i=0;i<m;i++)
printf
(
"%2d "
,d[i]);
printf
(
"\n"
);
free
(d);
return
0;
}