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. public static void main()
  11. {
  12. a1(new int[]{1, 2, 3, 4});
  13. a1(new int[]{4, 1, 2, 3});
  14. a1(new int[]{1, 1, 2, 2});
  15. a1(new int[]{1, 1});
  16. a1(new int[]{1});
  17. a1(new int[]{});
  18. }
  19.  
  20. static int a1(int[] a)
  21. {
  22. int max1 = -1;
  23. int max2 = -1;
  24.  
  25. for (int i=0; i<a.length; i++)
  26. {
  27. if (a[i] > max1)
  28. {
  29. max2 = max1;
  30. max1 = a[i];
  31. }
  32. else if (a[i] != max1 && a[i] > max2)
  33. max2 = a[i];
  34. }
  35.  
  36. return max2;
  37. }
  38. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
spoj: The program compiled successfully, but main class was not found.
      Main class should contain method: public static void main (String[] args).
stdout
Standard output is empty