2017年8月26日 星期六

UVA10420:List of Conquests

  1. import java.util.*;  
  2. class main{  
  3. static String[] name = {"England","Spain"};  
  4. static int[] count = new int[2];  
  5. public static void main(String[] args){  
  6. Scanner sc = new Scanner(System.in);  
  7. int c = 0,size=sc.nextInt();  
  8. sc.nextLine();  
  9. for(int k = 0;k<size;k++){  
  10. String[] waman = sc.nextLine().split(" ");  
  11. for(int i =0;i<name.length;i++)  
  12.   if(name[i].equals(waman[0])){  
  13.     count[i]++; break ;  
  14.   }  
  15. }  
  16. for(int i=0;i<name.length;i++)  
  17.  if(count[i]!=0) System.out.println(name[i]+" "+count[i]);  
  18.   
  19.   
  20. }  
  21.   
  22. }  

沒有留言:

張貼留言

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