unsigned int iTemp =0;
printf("Get the number of the byte?");
int nByte;
scanf("%d",&nByte);
unsigned int byte[100];
for(int i = 0;i<nByte;i++)
{
printf("Get the byte No.%d",i);
scanf("%02x",&byte[i]);
}
for(i=0;i<nByte;i++)
{
iTemp ^= (byte[i]<<8);
for(int j=0;j<8;j++)
{
int flag = iTemp & 0x8000;
iTemp <<= 1;
if(flag)
{
iTemp ^= 0x1021;
}
}
}
printf("The number is %04x\r\n",iTemp);
printf("Get the number of the byte?");
int nByte;
scanf("%d",&nByte);
unsigned int byte[100];
for(int i = 0;i<nByte;i++)
{
printf("Get the byte No.%d",i);
scanf("%02x",&byte[i]);
}
for(i=0;i<nByte;i++)
{
iTemp ^= (byte[i]<<8);
for(int j=0;j<8;j++)
{
int flag = iTemp & 0x8000;
iTemp <<= 1;
if(flag)
{
iTemp ^= 0x1021;
}
}
}
printf("The number is %04x\r\n",iTemp);
int iTemp = 0;
Console.WriteLine("Get the number of the byte?");
int nByte;
nByte = int.Parse(Console.ReadLine());
int[] bt = new int[100];
for(int i = 0;i <nByte;i++)
{
Console.WriteLine("Get the byte No.{0}",i);
bt[i] = int.Parse(Console.ReadLine());
}
for(int i=0;i <nByte;i++)
{
iTemp ^= (bt[i] <<8);
for(int j=0;j <8;j++)
{
int flag = iTemp & 0x8000;
iTemp <<= 1;
if(flag != 0)
{
iTemp ^= 0x1021;
}
}
}
Console.WriteLine("The number is {0:X}",iTemp);
Console.WriteLine("Get the number of the byte?");
int nByte;
nByte = int.Parse(Console.ReadLine());
int[] bt = new int[100];
for(int i = 0;i <nByte;i++)
{
Console.WriteLine("Get the byte No.{0}",i);
bt[i] = int.Parse(Console.ReadLine());
}
for(int i=0;i <nByte;i++)
{
iTemp ^= (bt[i] <<8);
for(int j=0;j <8;j++)
{
int flag = iTemp & 0x8000;
iTemp <<= 1;
if(flag != 0)
{
iTemp ^= 0x1021;
}
}
}
Console.WriteLine("The number is {0:X}",iTemp);
printf => Console.WriteLine
scanf => Console.ReadLine