Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class RES {
- double ts [] = {7,-10,13,8,4,-7.2,-12,-3.7,3.5,-9.6,6.5,-1.7,-6.2,7};
- public double procheToZero (double ts[] 1){
- if (ts.length == 0) return 0;
- double proche = ts[0];
- for (double i: ts) {
- double abs = Math.abs (i);
- double absClosest = Math.abs ( proche);
- if (abs <absClosest) {
- proche = i;
- } else if (abs == absClosest && proche <0) {
- proche = i;
- }
- }
- return proche;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement