格雷玛
来源:互联网 发布:淘宝如何增加访客量 编辑:程序博客网 时间:2024/05/23 23:23
格雷码:给定一个二进制的位数n,求出一个0到2^n-1的排列,使得相邻两项排列(包括头尾相邻)的二进制表达中只有恰好一位不同。
比如:
数字 二进制
0 0000
1 0001
2 0011
3 0010
4 0110
5 0111
6 0101
等等……
由上面比较上下两个二进制可发现相邻两项排列只有恰好只有一位不同,这就是格雷码。
其C++程序为:
vector<int>Gray_Create(int n){ vector<int>res; for(int i=0;i<(1<<n);i++) res.push_back(i^(i>>1)); return res;}
0 0
- 格雷玛
- [Linux] VIM 代码折叠
- nyoj-975-关于521
- 程序设计入门
- oracle命令学习笔记(一)
- helloandriod] ActivityManager: Warning: Activity not started, its current task has been brought to t
- 格雷玛
- Gromacs源码收获(四)
- g++ 错误error: invalid use of incomplete type
- MySQL SQL优化:Percona优化器真的好吗?
- 数据库范式
- 【String转Integer】String to Integer (atoi)
- 数据库查询语句的左连接和右连接
- bzoj1042 HAOI2008 硬币购物 容斥原理
- NPAPI插件开发详细记录:插件的调试