fork 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. static int getNextInt(Reader in) throws IOException {
  11. int c;
  12. boolean negative = false;
  13. do {
  14. c = in.read();
  15. if (!Character.isDigit(c)) {
  16. negative = c == '-';
  17. }
  18. } while (c != -1 && !Character.isDigit(c));
  19. if (c == -1) return Integer.MIN_VALUE;
  20.  
  21. int num = Character.getNumericValue(c);
  22. while ((c = in.read()) != -1 && Character.isDigit(c)) {
  23. num = 10 * num + Character.getNumericValue(c);
  24. }
  25. return negative ? -num : num;
  26. }
  27.  
  28. public static void main (String[] args) throws java.lang.Exception
  29. {
  30.  
  31. int num;
  32. while ((num = getNextInt(reader)) != Integer.MIN_VALUE) {
  33. System.out.println(num);
  34. }
  35. }
  36. }
Success #stdin #stdout 0.04s 2184192KB
stdin
1 2 3 4 5

6 7 8 9 10

-15
stdout
1
2
3
4
5
6
7
8
9
10
-15