fork download
  1. import java.util.*;
  2.  
  3. public class ColaSerena {
  4.  
  5. public static void main(String[] args) {
  6. Scanner entrada = new Scanner(System.in);
  7. LinkedList<Short> fila = new LinkedList<Short>();
  8. do {
  9. String suceso = entrada.next();
  10. if (suceso.contains("fin")) {
  11. break;
  12. } else if (suceso.contains("cuenta")) {
  13. System.out.println("personas en la cola: " + fila.size());
  14. } else if (suceso.contains("ingresa")) {
  15. int cedula = entrada.nextInt(); //cedula queda inutilizada
  16. short maximo = entrada.nextShort();
  17.  
  18. if (fila.size() < maximo) {
  19. fila.add(maximo);
  20. //creo una iteracion que recorra la lista de maximos,
  21. //uno por uno, para ver
  22. //quienes salen y quienes se quedan en ambas listas
  23. for (int i = 0; i < fila.size(); i++) {
  24. if (fila.size() > fila.get(i)) {
  25. fila.remove(i);
  26. }
  27. }
  28. }
  29.  
  30. }
  31. } while (true);
  32. }
  33. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
ingresa 1000001 1
ingresa 1000001 2
cuenta
ingresa 1000001 2
ingresa 1000001 3
ingresa 1000001 4
cuenta
fin
compilation info
Main.java:3: error: class ColaSerena is public, should be declared in a file named ColaSerena.java
public class ColaSerena {
       ^
1 error
stdout
Standard output is empty