Gray Code In C

  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Gray Code In C as PDF for free.

More details

  • Words: 80
  • Pages: 1
#include <stdio.h> #include <stdlib.h> int main(void) { int i = 0, j, n, *g, *t; printf( "n: "); scanf( "%d", &n ); g = malloc( (n+2) * sizeof(int)); t = malloc( (n+2) * sizeof(int)); for (j=0; j <= n+1; j++) { g[j] = 0; t[j] = j+1; } while (i < n+1) { for (j=n; j; j--) printf( "%2d", g[j]); printf("\n"); i = t[0]; g[i] = !g[i]; t[0] = 1; t[i-1] = t[i]; t[i] = i+1; } return 0; }

Related Documents

Gray Code In C
June 2020 2
Michael C Gray
December 2019 9
Gray
November 2019 36
Hamilton - Code C++
July 2020 1
C Code Archive
November 2019 6