Advertisement
rafid_shad

delete index

Feb 15th, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.72 KB | None | 0 0
  1.  
  2. package ClassTheory;
  3.  
  4. import java.util.Scanner;
  5.  
  6. public class Fahim {
  7.     public static void main(String[] args) {
  8.         Scanner ss = new Scanner(System.in);
  9.         System.out.println("Enter how many element you want you in array");
  10.         int n=ss.nextInt();
  11.         int[] a=new int[n];
  12.         for (int i = 0; i <n; i++) {
  13.             a[i]=ss.nextInt();
  14.         }
  15.         System.out.println("Enter the index of element which you want to delete");
  16.         int d=ss.nextInt();
  17.         a[d]=0;
  18.         for (int i = 0; i < n; i++) {
  19.             if(a[i]==0){
  20.                 continue;
  21.             }else{
  22.                 System.out.print(a[i]+" ");
  23.             }
  24.         }
  25.         System.out.println("");
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement