Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.67 KB | None | 0 0
  1. /**
  2.  *
  3.  */
  4. package aceptaElReto;
  5.  
  6. import java.util.HashMap;
  7. import java.util.Map;
  8. import java.util.Scanner;
  9.  
  10. /**
  11.  * @author Ivan.Perez
  12.  *
  13.  *  https://github.com/IvanPerez9
  14.  */
  15. public class Problema268 {
  16.    
  17.       /*
  18.        * Acepta el reto 268
  19.        *
  20.        * 2 3
  21.        * 34 48
  22.        * 20 26 34
  23.        * 1 4
  24.        * 44
  25.        * 28 24 20 16
  26.        * 0 0
  27.        *
  28.        * TODO : Mostrarlo
  29.        *
  30.        */
  31.  
  32.       public static void main(String[] args) {
  33.         Scanner entrada = new Scanner(System.in);
  34.         int nPlatos = Integer.parseInt(entrada.next());
  35.         int nCoronas = Integer.parseInt(entrada.next());
  36.        
  37.         while (nPlatos != 0 && nCoronas != 0) {
  38.          
  39.           double[] platos = new double[nPlatos];
  40.           for (int i = 0; i < nPlatos; i++) {
  41.             platos[i] = Integer.parseInt(entrada.next());
  42.           }
  43.          
  44.           double[] coronas = new double[nCoronas];
  45.           for (int i = 0; i < nCoronas; i++) {
  46.             coronas[i] = Integer.parseInt(entrada.next());
  47.           }
  48.          
  49.           //Ordenarlos TODO
  50.           Map<String, Double> mapa = new HashMap<>();
  51.           for (double i : coronas) {
  52.             for (double j : platos) {
  53.                 String mostrar = (int)j +"-"+(int)i;
  54.                 double valor = j/i;
  55.                 mapa.put(mostrar, valor);
  56.             }
  57.           }
  58.          
  59.           // Error de mostrar
  60.          
  61.           mapa.entrySet()
  62.             .stream()
  63.             .sorted(Map.Entry.comparingByValue())
  64.             .forEach(System.out::print);
  65.          
  66.           for (String aux : mapa.keySet()) {
  67.             System.out.println(aux);
  68.           }
  69.          
  70.           // Actualizacion
  71.           nPlatos = Integer.parseInt(entrada.next());
  72.           nCoronas = Integer.parseInt(entrada.next());
  73.         }
  74.         entrada.close();
  75.       }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement