返回列表 發帖

TQC207

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

返回列表