标签:io os ar java for sp on amp line
package huawei;
import java.util.Scanner;
public class TestHuaWei {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int nCount = 0;
try {
if (in.hasNextLine()) {
String line = in.nextLine();
if (line != null && line.trim().length() > 128) {
System.out.println("输出错误");
}
String iArray [] = line.split(",");
for (int i = 0, size = iArray.length; i < size; i++) {
int num = Integer.valueOf(iArray[i]).intValue();
if (num == 1) {
nCount ++;
} else {
if ((num & (num - 1)) == 0) {
nCount ++;
}
}
}
}
}catch(Exception e) {
System.out.println("输入错误");
} finally {
if (in != null) {
in.close();
}
}
System.out.println(nCount);
}
}
标签:io os ar java for sp on amp line
原文地址:http://www.cnblogs.com/tiny-kong/p/4055193.html