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 swapAndPrint(int a, int b) {
  11. System.out.println("Before:\t" + a + " " + b);
  12. a = a + b;
  13. b = a - b;
  14. a = a - b;
  15. System.out.println("After:\t" + a + " " + b);
  16. }
  17. public static void main (String[] args) throws java.lang.Exception
  18. {
  19. System.out.println("Min-Min:");
  20. swapAndPrint(Integer.MIN_VALUE, Integer.MIN_VALUE);
  21. System.out.println("Min-Max:");
  22. swapAndPrint(Integer.MIN_VALUE, Integer.MAX_VALUE);
  23. System.out.println("Max-Min:");
  24. swapAndPrint(Integer.MAX_VALUE, Integer.MIN_VALUE);
  25. System.out.println("Max-Max");
  26. swapAndPrint(Integer.MAX_VALUE, Integer.MAX_VALUE);
  27. System.out.println("0-Min:");
  28. swapAndPrint(0, Integer.MIN_VALUE);
  29. }
  30. }
Success #stdin #stdout 0.1s 320512KB
stdin
Standard input is empty
stdout
Min-Min:
Before:	-2147483648 -2147483648
After:	-2147483648 -2147483648
Min-Max:
Before:	-2147483648 2147483647
After:	2147483647 -2147483648
Max-Min:
Before:	2147483647 -2147483648
After:	-2147483648 2147483647
Max-Max
Before:	2147483647 2147483647
After:	2147483647 2147483647
0-Min:
Before:	0 -2147483648
After:	-2147483648 0