-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathArray Operations Deletion.java
More file actions
39 lines (37 loc) · 1.09 KB
/
Array Operations Deletion.java
File metadata and controls
39 lines (37 loc) · 1.09 KB
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
import java.util.*;
public class Deletion {
public static void main(String[] args){
int n,m,p;
System.out.println("Enter the number of elements in array");
Scanner sc=new Scanner(System.in);
n=sc.nextInt();
// System.out.println("Enter the number of elements in array");
int a[]=new int[n];
int b[]=new int[n-1];
System.out.println("Enter Values");
for(int i=0;i<n;i++){
a[i]=sc.nextInt();
}
System.out.println("Enter the index value which you want to be Deleted: ");
m=sc.nextInt();
for(int i=0;i<a.length;i++) {
// if(i<m){
// b[i]=a[i];
// }
// else if(i==m){
// continue;
// }
// else {
// b[i]=a[i];
// }
if (i == m)
continue;
else
b[i] = a[i];
}
System.out.println("Elements are: ");
for(int i = 0; i<b.length; i++){
System.out.println(b[i]);
}
}
}