Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. class RES {
  2. double ts [] = {7,-10,13,8,4,-7.2,-12,-3.7,3.5,-9.6,6.5,-1.7,-6.2,7};
  3.  
  4.  
  5. public double procheToZero (double ts[] 1){
  6. if (ts.length == 0) return 0;
  7.  
  8. double proche = ts[0];
  9. for (double i: ts) {
  10. double abs = Math.abs (i);
  11. double absClosest = Math.abs ( proche);
  12. if (abs <absClosest) {
  13. proche = i;
  14. } else if (abs == absClosest && proche <0) {
  15. proche = i;
  16. }
  17. }
  18. return proche;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement