Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- import java.util.Scanner;
- public class task10 {
- /**
- * @param args the command line arguments
- */
- public static void prA(int a[]){
- for(int i=0; i<a.length; i++)
- System.out.print(a[i]+" ");
- }
- public static int[] remove2(int a[], int element){
- int flag=0;
- for(int i=0; i<a.length; i++){
- if(element==a[i]){
- flag++;
- }
- }
- if(flag==0){
- System.out.println("Not found");
- return a;
- }else{
- for(int i=0; i<a.length; i++){
- if(a[i]==element){
- a[i] = 0;
- }
- }
- }
- return a;
- }
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int a[] = {10, 20, 30, 40, 50};
- System.out.println("The source array");
- prA(a);
- System.out.println();
- System.out.println("ENter the element");
- int e = sc.nextInt();
- remove2(a, e);
- prA(a);
- // TODO code application logic here
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement