您的位置:首页 > 其它

uva729 The Hamming Distance Problem

2013-07-20 20:21 435 查看

uva729 The Hamming Distance Problem 

全排列水题

存1的时候要注意位置。。。 刚开始因为这个不小心wa了

#include <algorithm>
using namespace std;
#include <stdio.h>
#include <string.h>

int t;
int n, h;
int i;
char sb[25];
int main()
{
scanf("%d", &t);
while (t --)
{
memset(sb, '0', sizeof(sb));
scanf("%d%d", &n, &h);
for(i = n - 1; i > n - 1 - h; i --)
{
sb[i] = '1';
}
sb
= '\0';
printf("%s\n", sb);
while (next_permutation(sb, sb + n))
{
printf("%s\n", sb);
}
if(t)
printf("\n");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ACM UVA