Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package NaimaD;
- import java.util.Scanner;
- import java.util.*;
- public class aaa
- {
- public static void main(String args[])
- {
- Scanner sc = new Scanner(System.in);
- int i,n,pos;
- System.out.println("Enter the number of elements:") ;
- n = sc.nextInt();
- int[] a = new int[n];
- System.out.println("Enter the elements") ;
- for(i=0;i<n;i++)
- {
- a[i] = sc.nextInt();
- }
- System.out.println("Enter the position of the number which is to be deleted");
- pos = sc.nextInt();
- for(i=pos;i<n-1;i++)
- {
- a[i]=a[i+1];
- }
- n=n-1;
- System.out.println("\nNew elements are: \n");
- for(i=0;i<n;i++)
- {
- System.out.println(a[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement