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 (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. Scanner sc = new Scanner(System.in);
  14. int[] arr = new int[7];
  15. for(int i = 0; i < 7; i++){
  16. int j = sc.nextInt();
  17. //sc.nextLine();
  18. arr[i] = j;
  19. }
  20.  
  21. int sum = 0;
  22. int count = 0;
  23. int limit1 = arr[5];
  24. int limit2 = arr[6];
  25. for(int i = 0; i < 5; i++){
  26. if(arr[i] > limit1 && arr[i] < limit2){
  27. sum += arr[i];
  28. count++;
  29. }
  30. }
  31. System.out.println(sum / count);
  32. }
  33. }
Success #stdin #stdout 0.11s 54520KB
stdin
100
200
300
400
500
100
500
stdout
300