Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. package NaimaD;
  2.  
  3. import java.util.Scanner;
  4. import java.util.*;
  5.  
  6. public class aaa
  7. {
  8. public static void main(String args[])
  9. {
  10. Scanner sc = new Scanner(System.in);
  11.  
  12. int i,n,pos;
  13.  
  14. System.out.println("Enter the number of elements:") ;
  15. n = sc.nextInt();
  16. int[] a = new int[n];
  17.  
  18. System.out.println("Enter the elements") ;
  19. for(i=0;i<n;i++)
  20. {
  21. a[i] = sc.nextInt();
  22. }
  23.  
  24.  
  25. System.out.println("Enter the position of the number which is to be deleted");
  26. pos = sc.nextInt();
  27.  
  28. for(i=pos;i<n-1;i++)
  29. {
  30. a[i]=a[i+1];
  31. }
  32. n=n-1;
  33.  
  34. System.out.println("\nNew elements are: \n");
  35. for(i=0;i<n;i++)
  36. {
  37. System.out.println(a[i]);
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement