Answers for "min_value java"

0

min in java

System.out.println(Math.min(a, b));
Posted by: Guest on March-01-2021
0

find min number in java

int[] arr = {2, 3, 4, 5, 6, 7, 8, 9,};
        int max = arr[0]; // max tanimliyorsun
        int min = arr[0];  // min tanimliyorsun

        for (int i = 0; i < arr.length; i++) {
            if (arr[i] > max){ 
// array's index are compared with each other,
// whichever is greater will be assigned to max
                max = arr[i];
            }
            if(arr[i] < min){ 
//array's index are compared with each other,
// whichever is smaller will be assigned to min
                min = arr[i];
            }
        }
        System.out.println(max); // 9
        System.out.println(min);  // 2
Posted by: Guest on June-09-2021
-2

java min function

void shift_solution(int & x, int & y, int a, int b, int cnt) {
    x += cnt * b;
    y -= cnt * a;
}

int find_all_solutions(int a, int b, int c, int minx, int maxx, int miny, int maxy) {
    int x, y, g;
    if (!find_any_solution(a, b, c, x, y, g))
        return 0;
    a /= g;
    b /= g;

    int sign_a = a > 0 ? +1 : -1;
    int sign_b = b > 0 ? +1 : -1;

    shift_solution(x, y, a, b, (minx - x) / b);
    if (x < minx)
        shift_solution(x, y, a, b, sign_b);
    if (x > maxx)
        return 0;
    int lx1 = x;

    shift_solution(x, y, a, b, (maxx - x) / b);
    if (x > maxx)
        shift_solution(x, y, a, b, -sign_b);
    int rx1 = x;

    shift_solution(x, y, a, b, -(miny - y) / a);
    if (y < miny)
        shift_solution(x, y, a, b, -sign_a);
    if (y > maxy)
        return 0;
    int lx2 = x;

    shift_solution(x, y, a, b, -(maxy - y) / a);
    if (y > maxy)
        shift_solution(x, y, a, b, sign_a);
    int rx2 = x;

    if (lx2 > rx2)
        swap(lx2, rx2);
    int lx = max(lx1, lx2);
    int rx = min(rx1, rx2);

    if (lx > rx)
        return 0;
    return (rx - lx) / abs(b) + 1;
}
Posted by: Guest on May-27-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language