write a program for finding the union of two integer array
in java?
Answers were Sorted based on User's Feedback
Answer / satish kumar
void union(int x[],int y[])
{
int n=x.length + y.length ;
int z[]=new int[n];
int p=x.length;
for(int i=0;i<x.length;i++)
{
z[i]=x[i];
}
int j=0;
for(int i=0;i<y.length;i++)
{
for(j=0;j<x.length;j++)
{
if(y[i]!=z[j])
{
continue;
}
else
{
if(y[i]==z[j])
break;
}
}
if(j==x.length)
z[p++]=y[i];
}
| Is This Answer Correct ? | 32 Yes | 24 No |
Answer / nadeem khokhar
the above mentioned code is also good one. but i m giving you an algorithm you can say, so you can get the concept and convert it into any language
int a[3]=1,2,3;
int b[3]=2,3,4;
for(int i=0; i <=2; i++)
{
for(int j=0; j<=2; j++)
{
if(a[i] == b[j])
cout<<a[i]; is a union of a and b
}
}
| Is This Answer Correct ? | 14 Yes | 26 No |
what is the use MDM(Master Data Management)and meaning
Write a program to reverse a number?
1. What coding languages are you comfortable with?
how to generate dsnless connectivity in j2ee
how do i create my own exception class which will restrict IO exception?
Display names and numbers of employees who have 5 years or more experience and salary less than Rs.15000 using array of structures (name, number, experience and salary)
what is meant by trigger?
What is a programming language?
I am looking for selenium RC online Training in chennai. can any one tell me the best institute
Explain recursion with an example.
When you deliver your C++ headers and C++ library of a class (what all can you change in the class so that application using your class does not need to recompile the code)
how do u handle table control inbdc explain the process in steps iwant the answer in urgent please forward this even i know how to explain there