fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner s = new Scanner(System.in);
  13. int wynik = 0;
  14. int liczba;
  15. int poprzednia = 42;
  16. while (s.hasNext()) {
  17. liczba = s.nextInt();
  18. System.out.println(liczba);
  19. if (liczba != 42) {
  20. poprzednia = liczba;
  21. } else if (liczba == 42 && poprzednia != 42) {
  22. wynik += 1;
  23. if (wynik == 3) {
  24. System.exit(0);
  25. }
  26. }
  27. }
  28. }
  29. }
Success #stdin #stdout 0.09s 35380KB
stdin
42
42
12
13
42
11
42
43
42
42
99
01
stdout
42
42
12
13
42
11
42
43
42