//計算數列 import java.io.*; public class na08{ public static void main(String args[]) throws Exception { //程式進入點 String getbr; BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); int i,max,min,count; /*****請使用者輸入數字**********/ while (true) { do { System.out.print("請輸入一個大於0的整數:"); getbr = br.readLine(); if (getbr.equals("0")) //判斷結束 { System.out.println("結束!"); return; } i=Integer.parseInt(getbr); if (i<0) //輸入錯誤 System.out.println("錯誤,請輸入大於0的整數"); } while (i<0) ;//輸入部分 count=0; max=i; min=i; while (i!=1) { count=count+1; if (i%2 == 0) //偶數 i=i/2; else //奇數 i=i*3+1; System.out.println(count+"->"+i); if (i>max) max=i; if (i"+max+" min->"+min); }//While true } }