string转为int然后取得int的值,然后与运算,再转为2进制,再转回string
解决方案 »
- 在hibernate中引入proxool连接池
- 面试问题:举个实际例子说明swtich…case的用法和使用约束?
- 关于SSH,SSI框架的问题
- struts2怎样设置不处理异常
- weblogic是用来干什么的?:)
- 该怎么提高我的技术呢?真的最近感到很苦恼,
- request.removeAttribute为什么移不掉值???在线等
- Web Service(Axis)中如果参数或者返回值为ArrayList或者Vector,该如何处理?
- weblogic8.1配置问题
- j2ee配置问题,在线等待。
- Tomcat的网站路径问题(可给350分)
- >>>>谁有Google Web APIs,给偶发一份,谢谢<<<<
{
public static void main(String[] args)
{
String s1 = new String("101011");//43
String s2 = new String("000101");//5
String s3 = new String("101001");//41
int i1 = getint(s1);
int i2 = getint(s2);
int i3 = getint(s3);
String s = new String(""); try
{
s = String.valueOf((i1&i2&i3));
}
catch(Exception e)
{
System.err.println(e);
}
System.out.println("s: " + s);
}
public static int getint(String s)
{
int i = 0;
int lengths = s.length();
int p = 0;
int si = 0;
String sc = new String("");
for(int j = 0; j < lengths; j++)
{
sc = String.valueOf(s.charAt(j));
si = Integer.parseInt(sc);
p = power(2,(lengths - j - 1));
i += p*si;
}
return i;
}
public static int power(int a, int p)
{
int res = 1; for(int i = 0; i < p; i++)
res*=a;
return res;
}
}