- Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathInverseOfArray.java
More file actions
Latest commit
46 lines (27 loc) · 684 Bytes
/
Copy pathInverseOfArray.java
File metadata and controls
46 lines (27 loc) · 684 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
importjava.util.Scanner;
publicclassInverseOfArray {
privatestaticvoidDisplay(intarr[])
{
for (intval : arr) {
System.out.println(val);
}
}
publicstaticint[] inverse(int[] a){
int[] inv = newint[a.length];
for (inti = 0; i < a.length; i++) {
intnum = a[i];
inv[num]=i;
}
returninv;
}
publicstaticvoidmain(String[] args) {
Scannerscn = newScanner(System.in);
inttc = scn.nextInt();
intarr[] = newint[tc];
for (inti = 0; i < arr.length; i++) {
arr[i] = scn.nextInt();
}
int[] inv = inverse(arr);
Display(inv);
}
}