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 int min(int a, int b, int c, int d)
  11. {
  12. int mass[]=new int[4];
  13. mass[0]=a;
  14. mass[1]=b;
  15. mass[2]=c;
  16. mass[3]=d;
  17. for(int i=0;i<4;i++)
  18. {
  19. if(mass[i]>mass[i+1])
  20. {
  21. int temp=mass[i];
  22. mass[i]=mass[i+1];
  23. mass[i+1]=temp;
  24. }
  25.  
  26. }
  27. int R=mass[0];
  28. return R;//напишите тут ваш код
  29. }
  30.  
  31. public static int min(int a, int b)
  32. {
  33. if(a>b)
  34. return b;
  35. else
  36. return a;//напишите тут ваш код
  37.  
  38. }
  39.  
  40. public static void main(String[] args) throws Exception
  41. {
  42. System.out.println( min(-20, -10) );
  43. System.out.println( min(-20, -10, -30, -40) );
  44. System.out.println( min(-20, -10, -30, 40) );
  45. }
  46. }
Runtime error #stdin #stdout #stderr 0.09s 320576KB
stdin
Standard input is empty
stdout
-20
stderr
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 4
	at Ideone.min(Main.java:19)
	at Ideone.main(Main.java:43)