UVa 729 - The Hamming Distance Problem
来源:互联网 发布:2016淘宝代销选货技巧 编辑:程序博客网 时间:2024/05/29 18:32
题目链接:UVa 729 - The Hamming Distance Problem
求下一个排列的水题,不过我还是学习到了一些东西。
a是char数组,可以使用memset(a,0,sizeof(a)) 清空a,这道题必须清空。以前经常使用这个函数给整型或者bool型的数组赋初值了,还没用过这个函数对char数组赋初值。
还有一个问题我特想知道,这个题怎么优化,怎么那么多大神提交的代码那么快.....
#include <iostream>#include <algorithm>#include <cstring>using namespace std;const int MAX_N = 16 + 2;int H,N,T;char a[MAX_N];int main(){ cin>>T; while(T--) { memset(a,0,sizeof(a)); cin>>N>>H; int i,j; for(i = 1;i <= H;i++) a[N-i] = '1'; for(j = 0;j < N - H;j++) a[j] = '0'; do { cout<<a<<endl; } while(next_permutation(a,a+N)); if(T) cout<<endl; } return 0;}
0 0
- UVa 729 The Hamming Distance Problem
- UVa 729 - The Hamming Distance Problem
- UVA 729 - The Hamming Distance Problem
- UVa 729 - The Hamming Distance Problem
- uva 729 - The Hamming Distance Problem
- uva 729 The Hamming Distance Problem
- UVa 729: The Hamming Distance Problem
- uva 729 The Hamming Distance Problem
- uva - 729 - The Hamming Distance Problem
- UVa 729 - The Hamming Distance Problem
- uva 729 - The Hamming Distance Problem
- uva 729 - The Hamming Distance Problem
- UVa 729 - The Hamming Distance Problem 排列组合
- UVa 729 - The Hamming Distance Problem
- UVa 729 - The Hamming Distance Problem
- UVA 729 - The Hamming Distance Problem
- UVa-729-The Hamming Distance Problem
- UVA - 729 The Hamming Distance Problem
- 397高校毕业设计选题
- android 项目更改包名的方法
- 登录判断 之 asp.net 使用继承类的Session,判断用户是否登录
- Android ListView中item view重复使用带来的问题
- 浅谈数字签名
- UVa 729 - The Hamming Distance Problem
- sum of all integer numbers(坑题,水题)
- NSURL汉字UTF8编码
- C++调用C# DLL函数简单介绍
- 401高校毕业设计选题
- Ubuntu无法连接无线网
- VirtualBox 安装linux后,安装增强功能出错
- Hadoop-2.2.0集群安装配置实践
- 26高校毕业设计选题