标签:
import java.util.LinkedHashMap; import java.util.Map; import java.util.Scanner; public class MainVote1 { public static void main(String[] args) { LinkedHashMap<Character,Integer> hs=new LinkedHashMap<Character,Integer>(); Scanner sca=new Scanner(System.in); sca.nextLine(); char ch1[]=sca.nextLine().toCharArray(); sca.nextLine(); char ch2[]=sca.nextLine().toCharArray(); for(int i=0;i<ch1.length;i=i+2) hs.put(ch1[i], 0); int Invalid=0; for(int i=0;i<ch2.length;i=i+2){ if(hs.containsKey(ch2[i])){ int temp=hs.get(ch2[i]); hs.put(ch2[i], temp+1); } else Invalid++; } for(Map.Entry<Character, Integer> me:hs.entrySet()) System.out.println(me.getKey()+" : "+me.getValue()); System.out.print("Invalid : "+Invalid); } }
标签:
原文地址:http://www.cnblogs.com/GumpYan/p/5791468.html