Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
863 B
3
Indexable
Never
public class Launcher {

    public static boolean arrays(int a[], int b[], int x) {
        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < b.length; j++) {
                if (a[i] + b[j] == x) {
                    return true;
                }
            }
        }
        return false;
    }

    public static void main(String[] args) {

        int[] a = {1,5,13,2};
        int[] b = {8,3001,14};
        
        int[] c = {1,2,3,4};
        int[] d = {-5,-5,-13,-99};
        
        int[] e = {1,2,3};
        int[] f = {};
        
        int x = 13; // target value for arrays A and B
        int y = -4; // target value for arrays C and D
        int z = 4; // target value for arrays E and F
        
        System.out.println(arrays(a, b, x)); // change arrays and target value

    }
}