把下面的C语言代码改成Java 代码
#include<stdio.h>#include<stdlib.h>intmain(){unsignedshorts[]={0x4500,0x0031,0x89F5,0...
#include<stdio.h>
#include<stdlib.h>
int main(){
unsigned short s[]={
0x4500,
0x0031,
0x89F5,
0x0000,
0x6e06,
0x0000,
0xdeb7,
0x455d,
0xc0a8,
0x00dc};
unsigned long i,sum=0;
for(i= 0 ; i < sizeof(s)/sizeof(short) ; i++){
sum+=s[i];
}
while(sum>>16){
sum = (sum>>16)+(sum&0xffff);
}
printf("%p",~sum);
return 0;
} 展开
#include<stdlib.h>
int main(){
unsigned short s[]={
0x4500,
0x0031,
0x89F5,
0x0000,
0x6e06,
0x0000,
0xdeb7,
0x455d,
0xc0a8,
0x00dc};
unsigned long i,sum=0;
for(i= 0 ; i < sizeof(s)/sizeof(short) ; i++){
sum+=s[i];
}
while(sum>>16){
sum = (sum>>16)+(sum&0xffff);
}
printf("%p",~sum);
return 0;
} 展开
1个回答
展开全部
unsigned short crc(unsigned char [] crc_pointer,unsigned short data_length)
{
unsigned short k,k0,bit_flag;
unsigned short int_crc=0xffff;
for (k=0;k<data_length;k++)
{
int_crc^=(crc_pointer)[k];
for(k0=0;k0<8;k0++)
{
bit_flag=int_crc&0x0001;
int_crc>>=1;
if (bit_flag==1)
int_crc^=0xa001;
}
}
return(int_crc);
}
{
unsigned short k,k0,bit_flag;
unsigned short int_crc=0xffff;
for (k=0;k<data_length;k++)
{
int_crc^=(crc_pointer)[k];
for(k0=0;k0<8;k0++)
{
bit_flag=int_crc&0x0001;
int_crc>>=1;
if (bit_flag==1)
int_crc^=0xa001;
}
}
return(int_crc);
}
追问
可以把包名类名加上一起吗
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |