package logics;
public class findDuplicate {
public static void main(String []args)
{
int arr[]=new int[]{1,2,3,4,5,6,7,8,1,8};
duplicate(arr);
}
public static void duplicate(int a[])
{
for(int i=0;i<a.length;i++)
{
for(int j=i+1;j<a.length;j++)
{
if( (i!=j) && a[i]==a[j])
System.out.printf("duplicate is %d \n",a[i]);
}
}
}
}//class
output:
-------------------
duplicate is 1
duplicate is 8
public class findDuplicate {
public static void main(String []args)
{
int arr[]=new int[]{1,2,3,4,5,6,7,8,1,8};
duplicate(arr);
}
public static void duplicate(int a[])
{
for(int i=0;i<a.length;i++)
{
for(int j=i+1;j<a.length;j++)
{
if( (i!=j) && a[i]==a[j])
System.out.printf("duplicate is %d \n",a[i]);
}
}
}
}//class
output:
-------------------
duplicate is 1
duplicate is 8
Không có nhận xét nào:
Đăng nhận xét