import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.swing.JOptionPane;
public class Test91 {
public static void main(String[] args) {
String s = JOptionPane.showInputDialog(null, "请输入句子:");
String[] ss = s.trim().split(" ");
Map map = new HashMap();
for (int i = 0; i < ss.length; i++) {
int count = 0;
for (int j = 0; j < ss.length; j++) {
if (ss[i].equals(ss[j])) {
count = count + 1;
}
}
//为了不打印重复的,放入map中去掉重复的
map.put(ss[i], count);
}
//遍历map,打印包含的单词和个数
Set key=map.keySet();
for (Iterator iterator = key.iterator(); iterator.hasNext();) {
String name = (String) iterator.next();
String count2=map.get(name).toString();
System.out.println(name+"有 "+count2+" 个");
}
}
}