返回列表 發帖
本帖最後由 johnson 於 2012-2-18 12:00 編輯 ! T: P7 ], r  M/ U
: Y, X: x+ f8 T# ~
import java.util.*;( {8 K1 `8 v; e2 K# X! B% G
public class j201
/ y( L' J' O  R1 y$ f; O  Y{9 b6 Q: [8 f/ y5 K0 w2 H! e
    public static void main(String arg[])9 f5 n% t6 a5 M% {
    {' G, r7 ~$ T/ b% [; ~
                Scanner s=new Scanner(System.in);/ g' u8 ~) G7 e6 i# @% P) Q
                System.out.print("請輸入Z可能的最大值:");' R5 @  m) i8 a* |4 N' |8 B
                int z=Integer.parseInt(s.next());
" _* Q  B  h; G$ @                int temp;
2 H! c+ T9 Q: A- p+ h                for(int x=1;x<=10;x++)- w4 e8 i+ b' A. c5 F* ^
                {
2 B3 Q1 {% y' Y2 V- N                        int y=x*x*3+x*2+1;( T& _! m; s! [  o2 p) m! n1 o
                        if(y<z)
+ Z$ i# H+ `( v+ z                        {  F! ]0 Y1 V$ S8 x
                                System.out.printf("x=%d,Y=%d,Z=%d,符合Y<Z的條件");
3 {# g7 n! V5 H, U* K. O. S5 L$ M                                break;
+ q" Z' U, t3 S  Y$ C8 g                        }+ ?# c! r4 s" p+ v. X/ u' m
                        temp=y;
4 ]/ J) F2 Y) L8 h/ X                }. g- w- i( r* k6 H- |+ O- B
    }7 K" E0 @1 v) I+ a* f4 o
}
小雲雀

TOP

  1. import java.util.*;
  2. public class j201
  3. {
  4.     public static void main(String arg[])
  5.     {
  6.                 Scanner s=new Scanner(System.in);
  7.                 System.out.print("請輸入Z可能的最大值:");
  8.                 int z=Integer.parseInt(s.next());
  9.                 int temp;
  10.                 for(int x=1;x<=10;x++)
  11.                 {
  12.                         int y=x*x*3+x*2+1;
  13.                         if(y<z)
  14.                         {
  15.                                 System.out.printf("x=%d,Y=%d,Z=%d,符合Y<Z的條件");
  16.                                 break;
  17.                         }
  18.                         temp=y;
  19.                 }
  20.     }
  21. }
複製代碼
小雲雀

TOP

返回列表