Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.io.IOException;
- public class Main {
- public static void main(String[] args) throws IOException {
- int nRange = 100;
- int someVar, test;
- int step = nRange / 100;
- int result = 0;
- int min = 0;
- int max = 0;
- int eps;
- int Hborder;
- int Lborder;
- int x = 0;
- boolean extremum = false;
- while (step >= eps) {
- min = 0;
- x = Lborder;
- extremum = false;
- while ((x <= Hborder) && !extremum) {
- System.out.println("Max " + x + max);
- if (min == 0 || max < min) {
- min = max;
- result = x;
- Lborder = x - step;
- } else {
- Hborder = x;
- extremum = true;
- }
- x = x + step;
- }
- step = step / 100;
- if (step < eps) {
- step = step * 10;
- }
- }
- eps = 0;
- System.out.println("Minimal distance = "+ min);
- System.out.println("X = "+ result);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment