public static void main(String[] args)
{
Map <String ,Integer> m =new HashMap<String , Integer>();
Scanner sc=new Scanner(System.in);
String str=sc.nextLine();
char c=str.toCharArray();
for(int i=0;i<c.lenght;i++)
{
if(m.containsKey(c[i]+""))
m.put(c[i]+"",++num);
else
num=1;
m.put(c[i]+"",num);
}
System.out.println(m);
}
时间: 2024-10-29 04:40:55