#include<stdio.h>
void main()
{int a[8],b[8];
int i=0,j=1;
printf("Please input this file into Gray code: \n");
for(;i<8;i++)
scanf("%d",&a[i]);
printf("\n Please Put a 8-bit binary files!\n ");
//以下是转换
b[0]=a[0];
for(;j<8;j++)
{if((a[j+1]+b[j])==0||a[j+1]+b[j]==2)
b[j]=0;
else if((a[j+1]+b[j])==1)
b[j]=1;
}
//输出格雷码
for(j=0;j<8;j++)
printf("%d ",b[j]);
system("pause");
}
void main()
{int a[8],b[8];
int i=0,j=1;
printf("Please input this file into Gray code: \n");
for(;i<8;i++)
scanf("%d",&a[i]);
printf("\n Please Put a 8-bit binary files!\n ");
//以下是转换
b[0]=a[0];
for(;j<8;j++)
{if((a[j+1]+b[j])==0||a[j+1]+b[j]==2)
b[j]=0;
else if((a[j+1]+b[j])==1)
b[j]=1;
}
//输出格雷码
for(j=0;j<8;j++)
printf("%d ",b[j]);
system("pause");
}