首页 > 其他 > 详细

记票统计

时间:2016-08-20 23:24:13      阅读:270      评论:0      收藏:0      [点我收藏+]

 

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!