public class TQC207 {! F' f/ z/ w8 J
% B% z0 n7 T4 {' d) M
7 V0 f8 s' e9 |
public static void main(String[] args) {
- i A& @+ y& ^3 L( B' r int sum=0, even=0, max=0, tmp=0;
& E( ]! t' c0 ~) g int[] nums = new int[args.length];. P& L& T- @: @' {# {; Z
try{
+ f3 t" m/ y8 t9 }* j for(int i=0 ; i<args.length ; i++){
% b( t5 \! O7 \, T- g+ M tmp= Integer.parseInt(args[i]);+ X/ q+ J n( F! U
nums[i] = tmp;+ h4 }1 d. L2 m3 D+ H
sum += tmp;
3 u. d4 E4 m y* E7 g- } if((tmp%2)==0); l! R) }! L9 l5 A7 n
even++;/ j% z- D% W6 l' j( @
max=Math.max(max,tmp);
1 o: ?5 J5 J' [& h + ?) u1 u- o. @+ D/ b
}
- o: ?, o/ Q# A0 r+ s6 h System.out.println("最大值"+"="+max);! F8 P6 ~- f K+ a( S
System.out.println("偶數的個數"+"="+even);' S6 v2 P; b# _
System.out.println("數字總和"+"="+sum);
6 E$ k6 j# K! e. _% B) V% h1 A
# K6 l9 }2 g5 Q3 S- `/ ` % @% w& y( Y, Y8 v' J- U
}
9 v8 c8 A1 k$ m% H2 o& Q& I catch(Exception e){7 E/ z, C9 j! U. f6 }8 E/ z; n
}
; v& t- k+ v) [% i) [( j" ~ }
" d" U. z+ E1 _} |