★★ Java の宿題ここで答えます Part 61 ★★
at TECH
157:デフォルトの名無しさん
07/05/31 00:40:49
>>153
import java.io.*;
public class Res153 {
public static void main(String[] args) throws IOException {
int[] n = new int[10];
System.out.println("データを入力してください");
for (String s : new BufferedReader(new InputStreamReader(System.in)).readLine().split("\\s+")) {
try {
n[Integer.parseInt(s)]++;
} catch (NumberFormatException e) {
} catch (ArrayIndexOutOfBoundsException e) {
}
}
for (int i = 0; i < n.length; i++) {
System.out.println(i + "\t" + n[i]);
}
}
}
0〜9以外の数字は無視する。
あと、コンパイルしたときに「データを入力してください」という表示は出せない。
実行したときには出るようにした。
次ページ続きを表示1を表示最新レス表示スレッドの検索類似スレ一覧話題のニュースおまかせリスト▼オプションを表示暇つぶし2ch
4150日前に更新/337 KB
担当:undef