Help needed.
I have to write a program for one of my classes and I'm kinda confused on what to do.
Here's the prog assignment:
==
A Gray Code is a sequence of binary numbers such that the numbers differ in exactly one bit. For example, a 2 bit Gray Code is 00, 01, 11, 10.
You are to write a program that:
1. has two global constants representing the number of rows and columns of a two-dimensional array
2. within main( ), creates an array using the global constants
3. reads an integer length (which represents the length of the requested Gray Code) from a file c:\gray.dat
4. within another function, fills the array with the Gray Code using array indexing notation, e.g., a[i]. Each entry of the array will be either a 0 or a 1.
5. within another function, writes your Gray Code to the file c:\gray.out using pointer notation, e.g., *aPtr, without using indices
The maximum number of columns for the array is 8; you need to determine the appropriate maximum number of rows.
There are a number of algorithms for calculating a Gray Code of a specific length. You are to use the following one:
1. a Gray Code of length 1 contains two numbers 0 and 1
2. a Gray Code of length n + 1 can be constructed from one of length n (call it GCn) by taking GCn and attaching a 0 at the end of each term in the sequence, then reversing the GCn and appending a 1 to each of the terms.
==
Any help would be greatly appreciated.
|