ACM Gray code

时间:2012-11-05 04:22:50
【文件属性】:

文件名称:ACM Gray code

文件大小:1KB

文件格式:CPP

更新时间:2012-11-05 04:22:50

Gray code

ACM Gray code 能accepted Description Gray code is an interesting code sequence and has many applications in computer science.No matter you have known it before or not, here are some introductions about its features: (1) Gray code has 2^n unique elements; (2) Each element contains n digits of O or l; (3) Each pair of adjacent elements has exactly one different digit. For example, when n = 2, one of the gray code sequences is: 00,01,11,10. Now, the task is quite simple, given a positive integer n, generate the corresponding Gray code sequence. Input Input may contain multiple test cases. Each test case consists of one positive integer n (n≤16), Input is terminated by a case with n = O, which should not be processed. Output For eacb test case, output the corresponding Gray code sequence, one element per line.There may be multiple answers, any of them will be accepted. Please output a blank line after each test case. Sample Input 1 2 O Sample Output O 1 00 01 11 10


网友评论

  • 哈哈,看了半天,没看懂,水平有限!!