- 157 名前:デフォルトの名無しさん mailto:sage [2007/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以外の数字は無視する。 あと、コンパイルしたときに「データを入力してください」という表示は出せない。 実行したときには出るようにした。
|

|