返回列表 發帖
  1. import java.util.Scanner;
  2. public class tqc201
  3. {
  4.     public static void main(String args[])
  5.     {
  6.         Scanner s=new Scanner(System.in);
  7.         System.out.print("請輸入Z可能的最大值: ");
  8.         int z=s.nextInt();
  9.         int temp=0;
  10.         for(int x=1;x<=100000;x++)
  11.         {
  12.             int y=(x*x)*3+x*2+1;
  13.             if(y>=z)
  14.             {
  15.                 System.out.println("當x="+(x-1)+"時,y="+temp+",z="+z+",符合y<z的條件");
  16.                 break;
  17.             }
  18.             temp=y;
  19.         }
  20.     }
  21. }
複製代碼

TOP

返回列表