Advertisement
Guest User

Untitled

a guest
Dec 15th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. package clases.pactometro;
  2.  
  3. import java.util.LinkedList;
  4. import java.util.List;
  5.  
  6. import us.lsi.common.Files2;
  7.  
  8. public class ProblemaMayoriaAbsoluta {
  9.  
  10. static Integer mayoriaAbsoluta;
  11. static List<Integer> resultadoElectoral = new LinkedList<Integer>();
  12. static List<List<Integer>> incompatibilidades = new LinkedList<List<Integer>>();
  13.  
  14. public static Integer getPartido(int i) {
  15. return resultadoElectoral.get(i);
  16. }
  17.  
  18. public static void iniciar() {
  19. mayoriaAbsoluta = 0;
  20. List<String> lineas1 = Files2.getLines("files/resultadoElectoral.txt");
  21. for(int i = 0 ; i < lineas1.size(); i++) {
  22. Integer escanios = Integer.parseInt(lineas1.get(i).trim());
  23. mayoriaAbsoluta += escanios;
  24. resultadoElectoral.add(escanios);
  25. }
  26.  
  27. mayoriaAbsoluta = (mayoriaAbsoluta / 2) + 1;
  28.  
  29.  
  30. List<String> lineas2 = Files2.getLines("files/incompatibilidades.txt");
  31. for(int indicePartido = 0; indicePartido < resultadoElectoral.size(); indicePartido++) {
  32. if(lineas2.size() < indicePartido) {
  33. break;
  34. }
  35. String linea = lineas2.get(indicePartido);
  36. if(linea == "" || linea == null) {
  37. continue;
  38. }
  39. String[] inc = linea.split(",");
  40. List<Integer> incompatibilidad = new LinkedList<Integer>();
  41. for(int k = 0; k < inc.length; k++) {
  42. incompatibilidad.add(Integer.parseInt(inc[k].trim()));
  43. }
  44. incompatibilidades.add(incompatibilidad);
  45. }
  46.  
  47.  
  48.  
  49.  
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement