// 計算最大連續非遞減的數字長度 import java.io.*; public class n4 { public static void main(String args[]) throws Exception { //程式進入點 String getbr; int max,cnt; //放非遞減數字長度 char now;//放被取出來的那個字母 int i; BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); while (true) { System.out.print("請輸入字串:"); getbr = br.readLine(); if (getbr.equals("0")) { System.out.println("結束"); return; } if (getbr.length()>10) { System.out.println("字串長度太長!請重新輸入!"); continue; } max=1; cnt=1; now=getbr.charAt(0); for (i=1;imax) max = cnt; } else cnt=1; now=getbr.charAt(i); }//for System.out.println("max="+max); } } }