返回列表 發帖
  1. import java.util.Scanner;
  2. public class AS02 {
  3.        
  4.         static float tri(float x, float y){
  5.                 return (x*y)/2;
  6.         }

  7.         public static void main(String[] args) {
  8.                 Scanner s=new Scanner(System.in);
  9.                 System.out.print("請輸入底: ");
  10.                 int a=s.nextInt();
  11.                 System.out.print("請輸入高: ");
  12.                 int b=s.nextInt();
  13.                 System.out.println("底"+a+",高"+b+"的三角形,面積為"+tri(a,b));

  14.         }

  15. }
複製代碼

TOP

返回列表