求帮助,搜狗网申在线测试题。

首先说明本题目的原意:以下程序是GBK编码和解码程序,根据编码过程encode(),将解码过程decode()补充完整。写出输出结果,输出结果是一句话。

public  class  Test  { 
public  static  void  encode(byte[]  in,  byte[]  out,  int  password) 

int  len  =  in.length; 


int  seed  =  password  ^  0x2c8f7672; 
for  (int  i  =  0  ;  i  <  len;  ++i)  { 
byte  a  =  (byte)(  (  in[i]  ^  seed  )  >>>  2  ); 
byte  b  =  (byte)(  (  (  ((int)in[i])  <<  10  )  ^  seed  )  >>>  (10-6)  ); 
a  &=  0x3f; 
b  &=  0xc0; 
out[i]  =  (byte)(a  |  b); 
seed  =  (((seed  <<  7)  ^  seed  ^  out[i])  +  536513); 






public  static  void  decode(byte[]  in,  byte[]  out,  int  password) 

int  len  =  in.length; 


int  seed  =  password  ^  0x2c8f7672; 
for  (int  i  =  0  ;  i  <  len;  ++i)  { 
//……


public  static  void  main(String  []  args)  throws  Exception 

int  password  =  0xa15ab37a; 
byte[]  buf1  =  {-80,  -86,  -85,  77,  23,  -94,  2,  77,  111,  -35,  -60,  68,  -62,  -128,  -113,  27,  84,  11,  0,  61,  13,  -43,  56,  -50,  39,  55,  -99,  114,  -28,  104,  -65,  91,  66,  -97,  52,  80,  -109,  -6,  11,  29,  -14,  98,  -16,  -95,  38,  37,  122,  -75,  72,  -54,  -56,  -86,  -112,  -28,  }; 
byte[]  buf2  =  new  byte[buf1.length]; 
decode(buf1,  buf2,  password); 
System.out.println(new  String(buf2,  "GBK")); 

//……填写适当的代码,然后运行,打印出结果。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值