標題:
TQC207
[打印本頁]
作者:
許逸瑋
時間:
2012-4-7 11:58
標題:
TQC207
public class TQC207 {
3 i: H! M: L8 `, D+ t" l
: c; }& |* X& u6 ~* c( l
9 J2 b5 [7 Q p, v: u. G+ f
public static void main(String[] args) {
9 z2 W$ |. _$ f( a% l6 S/ t. j
int sum=0, even=0, max=0, tmp=0;
% {. V- w2 _$ c( b) e0 v2 q" v5 f+ |) R
int[] nums = new int[args.length];
4 g( m( V8 ]" q
try{
+ k/ b3 H. w! j+ y5 q
for(int i=0 ; i<args.length ; i++){
* d+ s% J: G, E1 z: n
tmp= Integer.parseInt(args[i]);
' }2 q2 ~% s: V- L n |9 i
nums[i] = tmp;
; _8 e7 ^* _! B4 J5 o O
sum += tmp;
* U& I T2 I9 ?# u
if((tmp%2)==0)
: C) T1 q& ~0 Z. t
even++;
: t; o5 Y$ V6 H3 X
max=Math.max(max,tmp);
" a0 d% }; s. t# U
" _1 E4 `* k4 n; _. V
}
) x; }7 ^, j5 l y2 E- \
System.out.println("最大值"+"="+max);
8 [! R" v, V& D6 j; ]+ C
System.out.println("偶數的個數"+"="+even);
. i3 C4 c9 V- ~
System.out.println("數字總和"+"="+sum);
4 o( h* `" a3 _+ K& x
# l/ d6 ^: e! a1 c4 j& M/ r; d
* c& F* F% u7 P+ o1 J8 v
}
7 s9 o6 M) p9 p! H; y& r
catch(Exception e){
9 H5 s; A8 h2 t5 }& S9 d& l
}
) ?, D( J# x; n3 C. w: V; u
}
* |% E% o7 F. R) L* U0 j
}
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://seed.istak.org.tw/)
Powered by Discuz! 7.2