Untitled
unknown
plain_text
4 years ago
885 B
14
Indexable
// Online Java Compiler
// Use this editor to write, compile and run your Java code online
import java.util.Scanner;
class HelloWorld {
static int[] findBitwiseXOR(int B[], int n) {
int A[] = new int[n];
for(int i=0; i<n; i++) {
int result = 0;
for(int j=0; j<n; j++) {
if(i != j) {
result = result ^ B[j];
}
}
A[i] = result;
}
return A;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int B[] = new int[n];
for(int i=0; i<n; i++) {
B[i] = sc.nextInt();
}
int A[] = findBitwiseXOR(B, n);
for(int i=0; i<n; i++) {
System.out.println(A[i]);
}
}
}Editor is loading...