Advertisement
Mopencio

Untitled

Aug 15th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. import java.util.*;
  2. /**
  3. *
  4. * @author Usuario
  5. */
  6. public class Aer169 {
  7. Scanner in = new Scanner (System.in);
  8.  
  9. public boolean caso(){
  10.  
  11. boolean centinela;
  12. String apellido;
  13. String nombre;
  14. String minus;
  15. int numeroParticipantes = 0;
  16. int contador = 0;
  17.  
  18. HashMap<String, Integer> participantes = new HashMap<>();
  19.  
  20. do{
  21. apellido = in.next();
  22. centinela = apellido.equals("====");
  23. if(!centinela){
  24. numeroParticipantes++;
  25. nombre = in.next();
  26. minus = apellido.toLowerCase();
  27.  
  28. if(participantes.containsKey(minus)){
  29. participantes.put(minus, participantes.get(minus)+1);
  30. contador = participantes.get(minus)+1;
  31. }else{
  32. participantes.put(minus, contador);
  33. }
  34. }
  35. }while(!centinela);
  36.  
  37. System.out.format("%d %d%n",numeroParticipantes, contador);
  38.  
  39. return true;
  40. }
  41.  
  42. public void run(){
  43.  
  44. int numCaso = Integer.parseInt(in.nextLine());
  45. for(int i = 0; i < numCaso; i++){
  46. caso();
  47. }
  48.  
  49. }
  50. /**
  51. * @param args the command line arguments
  52. */
  53. public static void main(String[] args) {
  54. new Aer169().run();
  55. // TODO code application logic here
  56. }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement