fork download
  1. import java.io.BufferedReader;
  2. import java.io.InputStreamReader;
  3. import java.io.PrintWriter;
  4.  
  5. public class Test
  6. {
  7. public static void main(String[] args)
  8. {
  9. PrintWriter out = new PrintWriter(System.out);
  10. int length = 0;
  11. int count = 1;
  12. int max = 0;
  13. int maxnum = 0;
  14. try{
  15. length = Integer.parseInt(in.readLine());
  16. }catch (Exception e){}
  17. int[] arr = new int[length];
  18. for(int i=0;i<length;i++)
  19. {
  20. try{
  21. arr[i] = Integer.parseInt(in.readLine());
  22. }catch (Exception e){}
  23. }
  24. arr = qSort(arr,0,length-1);
  25.  
  26. for(int h=0;h<length;h++)
  27. {
  28. for(int l=1;l<length;l++)
  29. {
  30. if(arr[h] == arr[l])
  31. {
  32. count++;
  33. if(count > max)
  34. {
  35. max = count;
  36. maxnum = arr[h];
  37. }
  38. } else count = 0;
  39. }
  40. }
  41.  
  42. out.println(maxnum);
  43. out.flush();
  44.  
  45. }
  46.  
  47. public static int[] qSort(int[] A, int low, int high) {
  48. int i = low;
  49. int j = high;
  50. int x = A[(low+high)/2];
  51. do {
  52. while(A[i] < x) ++i;
  53. while(A[j] > x) --j;
  54. if(i <= j){
  55. int temp = A[i];
  56. A[i] = A[j];
  57. A[j] = temp;
  58. i++; j--;
  59. }
  60. } while(i < j);
  61.  
  62. if(low < j) qSort(A, low, j);
  63. if(i < high) qSort(A, i, high);
  64.  
  65. return A;
  66. }
  67. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:5: class Test is public, should be declared in a file named Test.java
public class Test
       ^
1 error
stdout
Standard output is empty