返回列表 發帖
  1. import java.util.Scanner;
  2. public class B
  3. {
  4.         public static void main(String[] args)
  5.         {
  6.                  int x=0,y=0;
  7.                  try
  8.                  {
  9.                         Scanner s=new Scanner(System.in);
  10.                         System.out.print("輸入分子: ");
  11.                         x=s.nextInt();
  12.                      System.out.print("輸入分母: ");
  13.                      y=s.nextInt();
  14.                      System.out.println(x+"/"+y+"="+(x/y));
  15.                  }
  16.                  catch(Exception e)
  17.                  {
  18.                          System.out.println("錯誤");
  19.                  }
  20.         }
  21. }
複製代碼

TOP

返回列表