2017年9月1日 星期五

UVA10226:Hardwood species

  1. import java.util.*;  
  2. class main{  
  3. public static void main(String[] args){  
  4. Scanner sc = new Scanner(System.in);  
  5. int count = sc.nextInt();sc.nextLine();sc.nextLine();  
  6. for(int i=0;i<count;i++){  
  7. TreeMap<String,Integer> map=new TreeMap();  
  8. String name=""int c=0;  
  9. while(sc.hasNext()&&!((name=sc.nextLine()).equals(""))){  
  10. if(map.containsKey(name)) map.put(name,map.get(name)+1);  
  11. else map.put(name,1);  
  12. c++;  
  13. }  
  14. if(i!=0) System.out.println();  
  15. for(Map.Entry<String,Integer> me:map.entrySet())  
  16.   System.out.printf("%s %.4f%n",me.getKey(),me.getValue()*100.0/c);  
  17.   
  18. }  
  19.   
  20.   
  21.   
  22. }  
  23.   
  24.   
  25. }  

沒有留言:

張貼留言

注意:只有此網誌的成員可以留言。