package com.woniuxy.demo;
import java.util.Scanner;
public class Homework10 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
System.out.println("输入字符");
String str = in.next();
char[] strc = str.toCharArray();
int[] s = new int[strc.length]; //记录个数
char[] newC = new char[strc.length];
for (int i = 0; i < strc.length; i++) { // 复制数列
newC[i] = strc[i];
}
for (int i = 0; i < strc.length; i++) {
for (int j = i + 1; j < strc.length; j++) {// 删除重复的值
if (strc[i] == strc[j]) {
strc[j] = ' ';
}
}
}
for (int i = 0; i < strc.length; i++) {
for (int j = 0; j < strc.length; j++) { // 复制的数组与删除重复的数组比较
if (strc[i] == newC[j]) {
s[i]++; // 每个字符个数
}
}
if (s[i] != 0) {
System.out.println("字符" + strc[i] + "有" + s[i] + "个");
}
}
}
}