andy6804tw
7/17/2016 - 12:43 PM

http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?a=15374 這題因為不知每一筆有幾個成績所以要放入字串中然後做切割

http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?a=15374 這題因為不知每一筆有幾個成績所以要放入字串中然後做切割

import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = Integer.parseInt(scn.nextLine());
		while (n-- != 0) {
			int arr[] = new int[11];
			String str = scn.nextLine(), s[] = str.split(" ");
			for (int j = 0; j < s.length; j++) {
				int num = Integer.parseInt(s[j]);
				if (num >= 0 && num <= 9)
					arr[0]++;
				else if (num >= 10 && num <= 19)
					arr[1]++;
				else if (num >= 20 && num <= 29)
					arr[2]++;
				else if (num >= 30 && num <= 39)
					arr[3]++;
				else if (num >= 40 && num <= 49)
					arr[4]++;
				else if (num >= 50 && num <= 59)
					arr[5]++;
				else if (num >= 60 && num <= 69)
					arr[6]++;
				else if (num >= 70 && num <= 79)
					arr[7]++;
				else if (num >= 80 && num <= 89)
					arr[8]++;
				else if (num >= 90 && num <= 99)
					arr[9]++;
				else if (num == 100)
					arr[10]++;
			}
			for (int i = 0; i < arr.length; i++)
				System.out.print(arr[i] + ",");
			System.out.println();
		}
	}
		/* 
    題目:[C_AR176-易] 任意個分數分佈統計
    作者:1010
    時間:西元 2016 年 7 月 */
}