/*题目描述:
将2^n个0,1排成一个环,每次取出其中连续的n位,这n位可以看成一个n位的2进制数。

现求一算法,生成2^n个0,1的一个排列,使得按照上述的取法,
0 ~ 2^n-1这2^n个数(每个数都看作n位的)恰好出现一次。

for example:
input:
3

output:
0,0,0,1,0,1,1,1

(依次取出的数是:000,001,010,101,011,111,110,100
十进制是:0,1,2,5,3,7,6,4;每个恰出现一次)




Comments

Good.Be the first to comment on this entry.

Post comment

comment has COPYRIGHT too!

Note: Commenter is allowed to use '@User+blank' to automatically notify your reply to other commenter. e.g, if ABC is one of commenter of this post, then write '@ABC '(exclude ') will automatically send your comment to ABC. Using '@all ' to notify all previous commenters. Be sure that the value of User should exactly match with commenter's name (case sensitive).