#include<stdio.h>
int dataGroup[4][16]=
{
{40,30,31,57,32,30,30,30,31},//AL1
{40,30,31,57,32,30,30,30,33},//AL2
{40,30,31,57,32,30,30,30,35},//AH1
{40,30,31,57,32,30,30,30,37}//AH2
};
void dealInputData(int,int,int,int);
void main()
{
int inputNum_AL1,inputNum_AL2,inputNum_AH1,inputNum_AH2;
int i;
scanf("%d %d %d %d",&inputNum_AL1,&inputNum_AL2,&inputNum_AH1,&inputNum_AH2);
dealInputData(inputNum_AL1,inputNum_AL2,inputNum_AH1,inputNum_AH2);
for(i=0;i<16;i++)
printf("%d ",dataGroup[0][i]);
}
void dealInputData(int inputNum_AL1,int inputNum_AL2,int inputNum_AH1,int inputNum_AH2)
{
int i,j;
int temp_AL1,temp_AL2,temp_AH1,temp_AH2;
/*得到4位AL1,AL2,AH1,AH2*/
for(i = 0; i < 4;i++)
{
if(i == 0)
{
dataGroup[0][10] = (inputNum_AL1 & 0xf)+30;
dataGroup[1][10] = (inputNum_AL2 & 0xf)+30;
dataGroup[2][10] = (inputNum_AH1 & 0xf)+30;
dataGroup[3][10] = (inputNum_AH2 & 0xf)+30;
}
else if(i == 1)
{
dataGroup[0][9] = (inputNum_AL1 & 0xf)+30;
dataGroup[1][9] = (inputNum_AL2 & 0xf)+30;
dataGroup[2][9] = (inputNum_AH1 & 0xf)+30;
dataGroup[3][9] = (inputNum_AH2 & 0xf)+30;
}
else if(i == 2)
{
dataGroup[0][12] = (inputNum_AL1 & 0xf)+30;
dataGroup[1][12] = (inputNum_AL2 & 0xf)+30;
dataGroup[2][12] = (inputNum_AH1 & 0xf)+30;
dataGroup[3][12] = (inputNum_AH2 & 0xf)+30;
}
else if(i == 3)
{
dataGroup[0][11] = (inputNum_AL1 & 0xf)+30;
dataGroup[1][11] = (inputNum_AL2 & 0xf)+30;
dataGroup[2][11] = (inputNum_AH1 & 0xf)+30;
dataGroup[3][11] = (inputNum_AH2 & 0xf)+30;
}
inputNum_AL1 = inputNum_AL1 >> 4;
inputNum_AL2 = inputNum_AL2 >> 4;
inputNum_AH1 = inputNum_AH1 >> 4;
inputNum_AH2 = inputNum_AH2 >> 4;
}
//得到校验位
temp_AL1 = 0;
temp_AL2 = 0;
temp_AH1 = 0;
temp_AH2 = 0;
for(j = 1;j < 13;j++)
{
temp_AL1=temp_AL1^dataGroup[0][j];
temp_AL2=temp_AL2^dataGroup[1][j];
temp_AH1=temp_AH1^dataGroup[2][j];
temp_AH2=temp_AH2^dataGroup[3][j];
}
dataGroup[0][13] = temp_AL1/10+30;
dataGroup[1][13] = temp_AL2/10+30;
dataGroup[2][13] = temp_AH1/10+30;
dataGroup[3][13] = temp_AH2/10+30;
dataGroup[0][14] = temp_AL1%10+30;
dataGroup[1][14] = temp_AL2%10+30;
dataGroup[2][14] = temp_AH1%10+30;
dataGroup[3][14] = temp_AH2%10+30;
dataGroup[0][15] = 0;
dataGroup[1][15] = 0;
dataGroup[2][15] = 0;
dataGroup[3][15] = 0;
}
int dataGroup[4][16]=
{
{40,30,31,57,32,30,30,30,31},//AL1
{40,30,31,57,32,30,30,30,33},//AL2
{40,30,31,57,32,30,30,30,35},//AH1
{40,30,31,57,32,30,30,30,37}//AH2
};
void dealInputData(int,int,int,int);
void main()
{
int inputNum_AL1,inputNum_AL2,inputNum_AH1,inputNum_AH2;
int i;
scanf("%d %d %d %d",&inputNum_AL1,&inputNum_AL2,&inputNum_AH1,&inputNum_AH2);
dealInputData(inputNum_AL1,inputNum_AL2,inputNum_AH1,inputNum_AH2);
for(i=0;i<16;i++)
printf("%d ",dataGroup[0][i]);
}
void dealInputData(int inputNum_AL1,int inputNum_AL2,int inputNum_AH1,int inputNum_AH2)
{
int i,j;
int temp_AL1,temp_AL2,temp_AH1,temp_AH2;
/*得到4位AL1,AL2,AH1,AH2*/
for(i = 0; i < 4;i++)
{
if(i == 0)
{
dataGroup[0][10] = (inputNum_AL1 & 0xf)+30;
dataGroup[1][10] = (inputNum_AL2 & 0xf)+30;
dataGroup[2][10] = (inputNum_AH1 & 0xf)+30;
dataGroup[3][10] = (inputNum_AH2 & 0xf)+30;
}
else if(i == 1)
{
dataGroup[0][9] = (inputNum_AL1 & 0xf)+30;
dataGroup[1][9] = (inputNum_AL2 & 0xf)+30;
dataGroup[2][9] = (inputNum_AH1 & 0xf)+30;
dataGroup[3][9] = (inputNum_AH2 & 0xf)+30;
}
else if(i == 2)
{
dataGroup[0][12] = (inputNum_AL1 & 0xf)+30;
dataGroup[1][12] = (inputNum_AL2 & 0xf)+30;
dataGroup[2][12] = (inputNum_AH1 & 0xf)+30;
dataGroup[3][12] = (inputNum_AH2 & 0xf)+30;
}
else if(i == 3)
{
dataGroup[0][11] = (inputNum_AL1 & 0xf)+30;
dataGroup[1][11] = (inputNum_AL2 & 0xf)+30;
dataGroup[2][11] = (inputNum_AH1 & 0xf)+30;
dataGroup[3][11] = (inputNum_AH2 & 0xf)+30;
}
inputNum_AL1 = inputNum_AL1 >> 4;
inputNum_AL2 = inputNum_AL2 >> 4;
inputNum_AH1 = inputNum_AH1 >> 4;
inputNum_AH2 = inputNum_AH2 >> 4;
}
//得到校验位
temp_AL1 = 0;
temp_AL2 = 0;
temp_AH1 = 0;
temp_AH2 = 0;
for(j = 1;j < 13;j++)
{
temp_AL1=temp_AL1^dataGroup[0][j];
temp_AL2=temp_AL2^dataGroup[1][j];
temp_AH1=temp_AH1^dataGroup[2][j];
temp_AH2=temp_AH2^dataGroup[3][j];
}
dataGroup[0][13] = temp_AL1/10+30;
dataGroup[1][13] = temp_AL2/10+30;
dataGroup[2][13] = temp_AH1/10+30;
dataGroup[3][13] = temp_AH2/10+30;
dataGroup[0][14] = temp_AL1%10+30;
dataGroup[1][14] = temp_AL2%10+30;
dataGroup[2][14] = temp_AH1%10+30;
dataGroup[3][14] = temp_AH2%10+30;
dataGroup[0][15] = 0;
dataGroup[1][15] = 0;
dataGroup[2][15] = 0;
dataGroup[3][15] = 0;
}
