Advertisement
knyazer

Untitled

Dec 8th, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.26 KB | None | 0 0
  1. double avg = 0;
  2. int n = 0;
  3.  
  4. for(int i = 0; i < arr.length; i++)
  5. {
  6. int x = arr[i];
  7.  
  8. if (Math.abs(x) % 2 == 1)
  9. {
  10. n++;
  11. avg += x;
  12. }
  13. }
  14.  
  15. if (n != 0)
  16. System.out.printf("%.2f", avg / n);
  17. else
  18. System.out.println("NO");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement