题目描述

输入样例:

100311

输出样例:

0:2
1:3
3:1

代码

package com.hbut.pat;
import java.util.Scanner;

public class Pat_1021 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int[]num = {0,0,0,0,0,0,0,0,0,0};
		int len = s.length();
		for(int i=0 ;i<len ;i++){
			num[s.charAt(i)-48]++;
		}
		for(int i=0 ;i<10 ;i++){
			if(num[i]!=0){
				System.out.printf("%d:%d\n",i,num[i]);
			}
		}
	}
}