UVA10226:Hardwood species
- import java.util.*;
- class main{
- public static void main(String[] args){
- Scanner sc = new Scanner(System.in);
- int count = sc.nextInt();sc.nextLine();sc.nextLine();
- for(int i=0;i<count;i++){
- TreeMap<String,Integer> map=new TreeMap();
- String name=""; int c=0;
- while(sc.hasNext()&&!((name=sc.nextLine()).equals(""))){
- if(map.containsKey(name)) map.put(name,map.get(name)+1);
- else map.put(name,1);
- c++;
- }
- if(i!=0) System.out.println();
- for(Map.Entry<String,Integer> me:map.entrySet())
- System.out.printf("%s %.4f%n",me.getKey(),me.getValue()*100.0/c);
-
- }
-
-
-
- }
-
-
- }
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。