Java201 解聯立方程式


package java實用級;

import java.util.Scanner;
import java.io.InputStreamReader;

public class J201 {

    public J201() {
        // TODO Auto-generated constructor stub
    }
    public static void main(String args[]) throws Exception
    {
    Scanner sc = new Scanner(System.in);
    int x=0,y=0,z,tmpx,tmpy;
    System.out.print("請輸入 Z 可能的最大值 : ");
    z=Integer.valueOf(sc.nextLine());
    do{
         tmpy=y;
         tmpx=x;
         x++;
         y=(int)(3*Math.pow(x,2))+x*2+1;
       }while(y<z);
    System.out.println(" = "+tmpx+", Y ="+tmpy+" , Z ="+z+",符合 Y < Z 的條件");


    }  
}

沒有留言:

張貼留言