返回列表 發帖
  1. public class TQC207
  2. {
  3.         public static void main(String[] args)
  4.         {
  5.                 int sum=0;
  6.                 int odd=0;
  7.                 int max=0;
  8.                 int tmp=0;
  9.                 int nums[]=new int[args.length];
  10.                 try
  11.                 {
  12.                         for(int i=0;i<args.length;i++)
  13.                         {
  14.                                 tmp=Integer.parseInt(args[i]);
  15.                                 nums[i]=tmp;
  16.                                 sum+=tmp;
  17.                                 if(tmp%2!=0)
  18.                                 {
  19.                                         odd ++;
  20.                                 }
  21.                                 max=Math.max(tmp,max);
  22.                         }
  23.                         System.out.println("最大值="+max);
  24.                         System.out.println("奇數的個數="+odd);
  25.                         System.out.println("數字的總合="+sum);
  26.                 }catch(Exception e)
  27.                 {
  28.                 }
  29.         }
  30. }
複製代碼
小雲雀

TOP

返回列表