publicstaticint[]binary2ten(Strings){char[]wm=newchar[s.length()];int[]shuiyin=newint[s.length()];int[]watermark=newint[s.length()/2];for(inta=0;a
public static int[] binary2ten(String s){
char []wm = new char[s.length()];
int []shuiyin = new int[s.length()];
int []watermark = new int[s.length()/2];
for(int a = 0; a < s.length(); a++)
wm = s.toCharArray();
//把string类型的二进制数据存到char型的wm数组中
for(int b = 0; b < (s.length()); b++){
shuiyin[b] = (wm[b] == '1' ? 1 : 0);
//把char型数组装换为int型数组
}
for(int c = 0; c < (s.length()); c+=2){
watermark[c/2] = (shuiyin[c] * 2) + shuiyin[c+1];
//两个为一组转换为3进制。
}
return shuiyin;//问题就是return不出来,换成print就可以。
}
return watermark;也没办法输出
展开