Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Scanner in = new Scanner(System.in);
- int jogadoresC = in.nextInt();
- int partidasL = in.nextInt();
- int matriz[][] = new int[partidasL][jogadoresC];
- double pontuacao[] = new double[jogadoresC];
- int jogadores[] = new int[jogadoresC];
- int f;
- int c;
- int colocacao = 0;
- int cont = 0;
- double calculo = 0;
- int i = 0;
- double aux = 0;
- int jogador = 1;
- int aux2 = 0;
- int contpartidas = 1;
- int teste = 0;
- int numerodepartidas=0;
- // entrada
- for (f = 0; f < partidasL; f++) {
- for (c = 0; c < jogadoresC; c++) {
- colocacao = in.nextInt();
- matriz[f][c] = colocacao;
- }
- }
- // calcular a pontua??o
- while (jogadoresC > cont) {
- for (f = 0; f < partidasL; f++) {
- colocacao = matriz[f][cont];
- if (jogador == colocacao && colocacao == contpartidas && jogador != 1) {
- contpartidas++;
- teste = 1;
- pontuacao[cont] = 0;
- } else if (teste == 0) {
- calculo = calculo + (1 / (colocacao * 0.5)) * (numerodepartidas+ 1);
- pontuacao[cont] = calculo;
- contpartidas++;
- numerodepartidas++;
- }
- }
- jogadores[cont] = jogador;
- cont++;
- jogador++;
- calculo = 0;
- contpartidas = 1;
- teste = 0;
- numerodepartidas=0;
- }
- for (int u = 0; u < jogadoresC; u++) {
- for (int j = 0; j < jogadoresC-1; j++) {
- if (pontuacao[j] < pontuacao[j + 1]) {
- aux = pontuacao[j];
- aux2 = jogadores[j];
- pontuacao[j] = pontuacao[j + 1];
- jogadores[j] = jogadores[j + 1];
- jogadores[j + 1] = aux2;
- pontuacao[j + 1] = aux;
- }
- }
- }
- System.out.println("O primeiro lugar foi: " + jogadores[0]);
- System.out.println("O segundo lugar foi: " + jogadores[1]);
- System.out.println("O terceiro lugar foi: " + jogadores[2]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement