搜狗 Java 在线测试 题目

nehc 2011-09-14 08:07:05
以下程序是一个信息编码的程序,阅读其encode部分,并补全其decode部分
最后运行程序,会打印出的一句话。这句话就是我们要求的答案。

注意!这句话是用GBK编码的!
答案请复制粘贴, 不要手动输入

public class Test {

public static void encode(byte[] in, byte[] out, int password) {
int len = in.length;

int seed = password ^ 0x3e1e25e6;
for (int i = 0; i < len; ++i) {
byte a = (byte) ((in[i] ^ seed) >>> 3);
byte b = (byte) (((((int) in[i]) << 18) ^ seed) >>> (18 - 5));
a &= 0x1f;
b &= 0xe0;
out[i] = (byte) (a | b);
seed = (seed * 84723701 ^ seed ^ out[i]);
}
}

public static void decode(byte[] in, byte[] out, int password) {
int len = in.length;
int seed = password ^ 0x3e1e25e6;
for (int i = 0; i < len; ++i) {
// fill the code here
}
}

public static void main(String[] args) throws Exception {
int password = 0xfdb4d0e9;
byte[] buf1 = { -5, 9, -62, -122, 50, 122, -86, 119, -101, 25, -64,
-97, -128, 95, 85, 62, 99, 98, -94, 76, 12, 127, 121, -32,
-125, -126, 15, 18, 100, 104, -32, -111, -122, 110, -4, 60, 57,
21, 36, -82, };
byte[] buf2 = new byte[buf1.length];
decode(buf1, buf2, password);
System.out.println(new String(buf2, "GBK"));
}
}

在线等候
...全文
484 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
阳明 to life 2011-09-15
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 marshallmathers 的回复:]

引用 4 楼 zhouyuqwert 的回复:
....整半天才整出来
Java code

public static void decode(byte[] in, byte[] out, int password)
{
int len = in.length;
int seed = password ^ 0x3e1e25e6;
for (int i = 0; i < l……
……
[/Quote]
..在纸上面画下 把那些位移来移去 a是取前面的5位 b是取后面3位
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 zhouyuqwert 的回复:]
....整半天才整出来
Java code

public static void decode(byte[] in, byte[] out, int password)
{
int len = in.length;
int seed = password ^ 0x3e1e25e6;
for (int i = 0; i < l……
[/Quote]

输入部分的
a &= 0xf8;
b &= 0x07;
是怎么得出来的啊?纠结好长时间了。
wxd_study111 2011-09-15
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 marshallmathers 的回复:]

引用 4 楼 zhouyuqwert 的回复:
....整半天才整出来
Java code

public static void decode(byte[] in, byte[] out, int password)
{
int len = in.length;
int seed = password ^ 0x3e1e25e6;
for (int i = 0; i < l……
……
[/Quote]同求
nehc 2011-09-15
  • 打赏
  • 举报
回复
请问:这是谁用我账号发的帖子?
这是谁用我账号发的帖子?
这是谁用我账号发的帖子?
这是谁用我账号发的帖子?
这是谁用我账号发的帖子?


我没有投搜狗啊 !!
teemai 2011-09-14
  • 打赏
  • 举报
回复
最近这题目咋这么多!而且是一样的
阳明 to life 2011-09-14
  • 打赏
  • 举报
回复
....整半天才整出来

public static void decode(byte[] in, byte[] out, int password)
{
int len = in.length;
int seed = password ^ 0x3e1e25e6;
for (int i = 0; i < len; ++i)
{
// fill the code here
byte a = (byte) ((in[i]<<3)^seed);
byte b = (byte) (((int)in[i]<<13^seed)>>18);
a &= 0xf8;
b &= 0x07;
out[i] = (byte)(a | b);
seed = (seed * 84723701 ^ seed ^ in[i]);

}
}

输出的是这玩意。。。太坑爹了
真双核引擎是全球最快的浏览器内核!!!!
xuweiman2010 2011-09-14
  • 打赏
  • 举报
回复
还可以用代码的方式 回复
我落伍了-.-!
xuweiman2010 2011-09-14
  • 打赏
  • 举报
回复
参考的网站上其他题目之后改的,自己还不是很理解

public static void decode(byte[] in, byte[] out, int password) {
int len = in.length;
int seed = password ^ 0x3e1e25e6;
for (int i = 0; i < len; ++i) {
// fill the code here
byte a = (byte) (in[i] & 0x1f);
byte b = (byte) (in[i] & 0xe0);
a = (byte) (((a << 3) ^ seed) & 0xf8);
b = (byte) (((b << (18-5) ^ seed) >> 18) & 0x07);
out[i] = (byte) (a | b);
seed = (seed * 84723701 ^ seed ^ in[i]);
}
}
2399 2011-09-14
  • 打赏
  • 举报
回复

byte a = (byte) (in[i] & 0x1f);
byte b = (byte) (in[i] & 0xe0);
a = (byte) (((a <<3) ^ seed) & 0xe0);
b = (byte) ((((((int) b) << (18 - 5)) ^ seed) >> 18) & 0x1f);
out[i] = (byte) (a | b);
seed = (seed * 84723701 ^ seed ^ in[i]);

62,616

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧