-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy patharray_insertion.java
38 lines (33 loc) · 955 Bytes
/
array_insertion.java
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
import java.util.Scanner;
public class array_insertion {
public static void main(String[] args) {
int num;
Scanner s = new Scanner(System.in);
num = s.nextInt();
int[] a = new int[num];
for(int i=0;i<num;i++)
a[i] = s.nextInt();
int pos = s.nextInt();
int in = s.nextInt();
for(int i = 0 ;i<num;i++)
{
if(i==pos-1)
System.out.print(in+" ");
System.out.print(a[i]+" ");
}
int size;
Scanner s = new Scanner(System.in);
size = s.nextInt();
int[] a = new int[size];
for(int i=0;i<a.length;i++)
a[i] = s.nextInt();
int pos = s.nextInt();
int ele = s.nextInt();
for(int i=0;i<size;i++)
{
if(pos-1==i){
System.out.print(ele+" ");
System.out.print(a[i]+" ");
}
}
}