返回列表 發帖
  1. import java.util.*;
  2. public class jva201
  3. {
  4.     public static void main(String arg[])
  5.     {
  6.         Scanner s = new Scanner(System.in);
  7.         System.out.print("請輸入 Z 可能的最大值:");
  8.         long  z = Integer.parseInt(s.next());
  9.         long tot=0;
  10.                 for(long  x=1;x<=100000;x++)
  11.                 {
  12.                 long  y = 3 * (x*x) + x*2 +1 ;
  13.                         if(y>z)
  14.                         {
  15.                         System.out.printf("當 x =%d 時, Y =%d , Z =%d,符合 Y < Z 的條件",x-1,tot,z);
  16.                         break;
  17.                         }
  18.                 tot=y ;
  19.                 }
  20.         }       
  21. }
複製代碼
水桶小鄭,鯰魚

TOP

返回列表