Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <bitset>
- #include <cmath>
- using namespace std;
- typedef unsigned char uc;
- const int size_uc = 8 * sizeof(uc);
- uc Gray(const uc &n) {
- return (n ^ (n >> 1));
- }
- int main() {
- cout << "n:";
- int n;
- cin >> n;
- for (int i = 0; i < pow(2, n); ++i) cout << bitset<size_uc>(Gray(i)) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment