標題:
106 數值過濾器
[打印本頁]
作者:
b790113g
時間:
2011-12-31 11:49
標題:
106 數值過濾器
本帖最後由 b790113g 於 2011-12-31 12:07 編輯
9 s ^1 T+ g" G# f7 z$ U, E4 a! j
+ s4 q9 @2 j0 J4 b9 A
不是數字就別加總
) P4 X5 [* N. v
: x" _+ {, z# o: \1 _
[attach]562[/attach]
作者:
TOM
時間:
2012-2-10 20:06
public class jva106
{
public static void main(String arg[])
{
int tot=0;
int isn=0;
int non=0;
for(int i=0;i<arg.length;i++)
{
try{
tot=tot+Integer.parseInt(arg[i]);
isn++;
}catch(Exception e){
non++;
}
}
System.out.println("數值之總和為:"+tot);
System.out.println("非數值個數為:"+non);
System.out.println("純數之個數為:"+isn);
}
}
複製代碼
救命!!!!!!!!為什麼不能執行
) N9 o# O; ]3 O. H
阿阿阿阿阿阿阿阿阿阿阿阿
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2