小编Cho*_*nic的帖子

如何从wireshark复制捕获的数据包的十六进制数据

这是一个示例,这是捕获的数据包数据

00000000  00 6e 0b 00                                                                          .n..
00000004  4d 5a e8 00 00 00 00 5b  52 45 55 89 e5 81 c3 81                    MZ.....[ REU.....
00000014  12 00 00 ff d3 89 c3 57  68 04 00 00 00 50 ff d0                       .......W h....P..
00000024  68 f0 b5 a2 56 68 05 00  00 00 50 ff d3 00 00 00                      h...Vh.. ..P.....
00000034  00 00 00 00 00 00 00 00  00 00 00 00 e0 00 00 …
Run Code Online (Sandbox Code Playgroud)

network-programming packet-capture wireshark

12
推荐指数
2
解决办法
1万
查看次数

选择数组中的数字,避免选择相同的数字?

我想创建一个函数,在数组中选择一个随机数,避免在下次选择相同的数字.
这是我的代码(它在某个时候工作,大多数是inf循环)

请帮帮我,谢谢.

private static int pick(int[] x) {
    int upperbound = x[x.length-1];
    int lowerbound = x[0];
    int count=0;
    int ranvalue;
    int ranindex;
    Random rand = new Random();

    do{
        ranindex = rand.nextInt(upperbound-lowerbound) + lowerbound;
        count++;
    }while(x[ranindex]==-1||count!=x.length-1);

    ranvalue=x[ranindex];
    x[ranindex]=-1;

    return ranvalue;
}
Run Code Online (Sandbox Code Playgroud)

java arrays

-3
推荐指数
1
解决办法
141
查看次数