Friday, 12 June 2015
Tuesday, 2 June 2015
Find the missing elements in the array - java program
public class MissingElement {
public static void main(String args[]){
int a[] = { 1,3,4,5,6,7,10 };
int j = a[0];
for (int i=0;i<a.length;i++)
{
if (j==a[i])
{
j++;
continue;
}
else
{
System.out.println(j);
i--;
j++;
}
}
}
}
Out put :
2
8
9
public static void main(String args[]){
int a[] = { 1,3,4,5,6,7,10 };
int j = a[0];
for (int i=0;i<a.length;i++)
{
if (j==a[i])
{
j++;
continue;
}
else
{
System.out.println(j);
i--;
j++;
}
}
}
}
Out put :
2
8
9
Subscribe to:
Comments (Atom)