Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.76 KB | None | 0 0
  1. Scanner in = new Scanner(System.in);
  2.  
  3.  
  4.  
  5. int jogadoresC = in.nextInt();
  6. int partidasL = in.nextInt();
  7. int matriz[][] = new int[partidasL][jogadoresC];
  8. double pontuacao[] = new double[jogadoresC];
  9. int jogadores[] = new int[jogadoresC];
  10. int f;
  11. int c;
  12. int colocacao = 0;
  13. int cont = 0;
  14. double calculo = 0;
  15. int i = 0;
  16. double aux = 0;
  17. int jogador = 1;
  18. int aux2 = 0;
  19. int contpartidas = 1;
  20. int teste = 0;
  21. int numerodepartidas=0;
  22.  
  23. // entrada
  24. for (f = 0; f < partidasL; f++) {
  25. for (c = 0; c < jogadoresC; c++) {
  26. colocacao = in.nextInt();
  27. matriz[f][c] = colocacao;
  28. }
  29. }
  30. // calcular a pontua??o
  31.  
  32. while (jogadoresC > cont) {
  33. for (f = 0; f < partidasL; f++) {
  34. colocacao = matriz[f][cont];
  35.  
  36. if (jogador == colocacao && colocacao == contpartidas && jogador != 1) {
  37. contpartidas++;
  38. teste = 1;
  39. pontuacao[cont] = 0;
  40.  
  41. } else if (teste == 0) {
  42. calculo = calculo + (1 / (colocacao * 0.5)) * (numerodepartidas+ 1);
  43. pontuacao[cont] = calculo;
  44. contpartidas++;
  45. numerodepartidas++;
  46.  
  47. }
  48. }
  49. jogadores[cont] = jogador;
  50. cont++;
  51. jogador++;
  52. calculo = 0;
  53. contpartidas = 1;
  54. teste = 0;
  55. numerodepartidas=0;
  56. }
  57.  
  58. for (int u = 0; u < jogadoresC; u++) {
  59. for (int j = 0; j < jogadoresC-1; j++) {
  60. if (pontuacao[j] < pontuacao[j + 1]) {
  61. aux = pontuacao[j];
  62. aux2 = jogadores[j];
  63. pontuacao[j] = pontuacao[j + 1];
  64. jogadores[j] = jogadores[j + 1];
  65. jogadores[j + 1] = aux2;
  66. pontuacao[j + 1] = aux;
  67. }
  68. }
  69. }
  70.  
  71. System.out.println("O primeiro lugar foi: " + jogadores[0]);
  72. System.out.println("O segundo lugar foi: " + jogadores[1]);
  73. System.out.println("O terceiro lugar foi: " + jogadores[2]);
  74.  
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement