729 - The Hamming Distance Problem
程序员文章站
2024-03-19 08:24:28
...
#include <cstdio>
#include <algorithm>
using namespace std;
int main()
{
//freopen("data.in","r",stdin);
int T;
scanf("%d",&T);
while(T--)
{
int h,n;
scanf("%d %d",&h,&n);
char str[20];
int i;
for(i=0;i<h-n;i++)
str[i]='0';
for(;i<h;i++)
str[i]='1';
str[i]=0;
do
{
printf("%s\n",str);
}while(next_permutation(str,str+i));
if(T)
printf("\n");
}
return 0;
}