There are two sorted arrays
a1 and a2 of size n1 and size n2 respectively.
array a1 is full
array a2 has exactly n1(size of array a1) empty space.
example
a1[]=1234
a2[]=56789_ _ _ _
Write a function to merge these two arrays to form a sorted
array without any extra memory use.
i want a solution in c/c++ language
Answer Posted / surjeet gangwar
import java.util.*;
class arrtest
{
int[][] a=new int[3][3];
int[][] b={{1,1,1},{1,1,1},{1,1,1}};
public arrtest()
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the matrix:\n");
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
a[i][j]=sc.nextInt();
}
void oper()
{
for(int i=0;i<3;i++)
for(int j=0;j<3;j++)
if(a[i][j]==0)
for(int k=0;k<3;k++)
{
b[i][k]=0;
b[k][j]=0;
}
}
void print()
{
System.out.println(" the matrix:\n");
for(int i=0;i<3;i++)
{ for(int j=0;j<3;j++)
System.out.print("\t"+b[i][j]);
System.out.println("\n");
}
}
}
class arrdemo
{
public static void main(String a[])
{
arrtest at=new arrtest();
at.oper();
at.print();
}
}
| Is This Answer Correct ? | 0 Yes | 3 No |
Post New Answer View All Answers
Concentrations of three wines A, B and C are 10, 20 and 30 percent respectively. They are mixed in the ratio 2 : 3 : x resulting in a 23% concentration solution. Find x.
Complete the series 2, 7, 24, 77,__ (hint: 2*12= 24, 7*11= 77, therefore 24*10= 240)
Two lemons cost 10 cents. Then one and a half dozen cost
Dinesh is seated 7 from the left and satish is seated 12 from the right. when they interchange their positions, dinesh is seated 22nd from the left. How many people are there?
complete the series: a c b d f e g i __
in a mixture, R is 2 parts, S is 1 part. in order to make S to 25% of the mixture, howmuch R is to be added
A bus started from bustand at 8.00a m and after 30 min staying at destination, it returned back to the bustand. the destination is 27 miles from the bustand. the speed of the bus 50 percent fast speed. at what time it retur4ns to the bustand
THERE ARE 3 PILES OF BOOKS ON THE TABLE YOU NEED TO ARRANGE THEM IN THE SELF SUCH THAT 1ST BOOK OF EACH PILE GETS PLACED ON THE SELF,WHAT IS THE POSSIBLE NO OF ARRANGEMENTS
Three years ago my uncle offered me a used keyboard for Rs. 1024. A year later he offered me the same for Rs. 640 and last year he wanted Rs. 400 and now he is willing to sell it to me for Rs. 250. But I have decided to buy it when he reduces the price next time. If he is constantly reducing its price, at what price will he offer the keyboard to me next?
low temperature at the night in a city is 1/3 more than ½ hinge as higher temperature in a day. sum of the low temp and higherst temp is 100C. then what is the low temperature
Price of product is reduced by 30%. What % should be increased to make it 100 % ?
A boy has Rs 2. He wins or loses Re 1 at a time If he wins he gets Re 1 and if he loses the game he loses Re 1. He can loose only 5 times. He is out of the game if he earns Rs 5. Find the number of ways in which this is possible?
A shopkeeper bought a watch for Rs.400 and sold it for Rs.500.What is his profit percentage?
If the ratio of the areas of 2 queres is 2:1, then the ratio of the perimeters of the squares is
If A=Z, B=Y, C=X, .......... Z=A, Then POCKET = ?