编译没问题,为什么通不过啊? java数据测试 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 for循环很可能死循环 没有跳出语句 也有健壮性问题吧//Testimport java.util.*;class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while(scanner.hasNext()) { int temp = 0; String str = null; try{ str = scanner.nextLine(); temp = Integer.parseInt(str);; while(temp >100000 || temp <0) { System.out.println("Please input a number between 0 and 100000!"); str = scanner.nextLine(); temp = Integer.parseInt(str); } }catch(NumberFormatException e) { System.out.println("You must input a number!"); e.printStackTrace(); } int num = 0; while(temp != 1) { if(temp % 2 == 0) { temp = temp / 2; }else { temp = (3*temp+1) / 2; } num ++; } System.out.println("num = " + num); } }} 怎样判断两个正则表达式是否包含或者交叉 求一个程序:五子棋游戏 很简单的问题,但现在搞不清楚问题出在那里,请帮忙.谢谢 java中图片文件头的处理 java线程为何无法停止 菜鸟问题:关于类变量与实例变量的区别 javabean的问题 think in java我看的是第一版,会不会产生什么误导呢? 为什么文字都成了问号??谁能帮我解决一下?up有分! 数据库操作只一次? 请问高手学习java中的困惑问题 急:求助java按序列编号排序(如1.2 ,1.11)
//Testimport java.util.*;class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while(scanner.hasNext()) {
int temp = 0;
String str = null;
try{
str = scanner.nextLine();
temp = Integer.parseInt(str);;
while(temp >100000 || temp <0) {
System.out.println("Please input a number between 0 and 100000!");
str = scanner.nextLine();
temp = Integer.parseInt(str);
}
}catch(NumberFormatException e) {
System.out.println("You must input a number!");
e.printStackTrace();
}
int num = 0;
while(temp != 1) {
if(temp % 2 == 0) {
temp = temp / 2;
}else {
temp = (3*temp+1) / 2;
}
num ++;
}
System.out.println("num = " + num);
}
}
}