Computer Science, asked by samlm10, 1 year ago

write a program in bluej to store 10 different numbers in a single dimensional array . display the numbers after eliminating duplicate numbers of the array.
SAMPLE INPUT:69 45 45 25 34 40 34 41 29 16
SAMPLE OUTPUT:69 45 25 34 40 41 29 16

Answers

Answered by pratikturkar306
5
class duplicate_terminate_number
{   
static void main(String[]args)   
{       
int []arr = {69,45,45,25,34,40,34,41,29,16};//Direct array input       
int b = arr.length;//length of the array       
for(int a=0;a<b-1;a++)       
{           
if(arr[a]!=arr[a+1])           
{                   
System.out.print(arr[a]+" ");           
}       
}   
}
}
         
                                                       Peace..!!




pratikturkar306: Hope it helps
samlm10: i asked to store and not to initialize
pratikturkar306: do you mean by user input?
samlm10: YES i mean so
samlm10: Plz help fast
pratikturkar306: Okay..!! just 5 mins
pratikturkar306: import java.util.*;
class duplicate_terminate_number
{
static void main(String[]args)
{
Scanner sc = new Scanner(System.in);
int[] arr = new int[10] ;

for(int c=0;c<10;c++)
{
arr[c]=sc.nextInt();
}
int b = arr.length;
for(int a=0;a<b-1;a++)
{
if(arr[a]!=arr[a+1])
{
System.out.print(arr[a]+" ");
}
}
}
}
pratikturkar306: okay now?
samlm10: Yep friend
samlm10: Plz solve my other comp questions
Similar questions