-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMixer.java
More file actions
52 lines (48 loc) · 994 Bytes
/
Copy pathMixer.java
File metadata and controls
52 lines (48 loc) · 994 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
47
48
49
50
51
52
import java.util.*;
public class Mixer
{
int arr[];
int n;
Mixer(int nn)
{
n=nn;
arr=new int[n];
}
void accept()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the elements of array in ascending order without any duplicates");
for(int i=0;i<n;i++)
{
arr[i]=sc.nextInt();
}
}
Mixer mix(Mixer A)
{
Mixer B=new Mixer(n+n);
for(int i=0;i<A.n;i++)
B.arr[i]=arr[i];
int k=n;
for(int i=0;i<A.n;i++)
{
B.arr[k]=A.arr[i];
k++;
}
return B;
}
void display()
{
for(int i=0;i<n;i++)
System.out.print(arr[i]+" ");
}
public static void main(int a)
{
Mixer ob=new Mixer(a);
Mixer ob1=new Mixer(a);
Mixer ob2=new Mixer(a+a);
ob.accept();
ob1.accept();
ob2=ob.mix(ob1);
ob2.display();
}
}