public static IList<int> GrayCode(int n)
{
List<int> result = new List<int>();
result.Add(0);
for (int i = 0; i < n; ++i)
for (int j = result.Count - 1; j >= 0; --j)
result.Add(result[j] + (int)Math.Pow(2, i));
}
return result;
No comments:
Post a Comment