先看代码
import java.util.Arrays; public class Main { public static void main(String[] args) { // TODO Auto-generated method stub int[] a = {9,5,4,3,7,3,2,1,2};//数据范围是0-10 int[] b = new int[11]; for(int i = 0;i<a.length;i++){ b[a[i]]++; } for(int i = 0;i<b.length;i++){ for(int j = 1;j<=b[i];j++){ System.out.println(i); } } } }
时间: 2024-12-11 14:39:34