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
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..!!
{
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
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]+" ");
}
}
}
}
Similar questions