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
If 15 pens costs Rs.90..then what will be the cost of 22pens?
A cubical rectangular bar has the dimensions with the ratio 5 : 4 : 3. Its volume is 7500. What is the surface area of the bar?
A moves 3 kms east from his starting point . He then travels 5 kms north. From that point he moves 8 kms east.How far is A from his starting point?
Pankaj walks east and turns right and then from there to his left and then 45degrees to his right. In which direction did Pankaj go?
With a 4/5 full tank a vehicle can travel 12 miles, how far can it travel with a 1/3 full tank
A company installed 36 punching machines at the begining of the year.In the spring they installed 9 additional m/c's and then discontinued 18 in the fall.How many were still installed at the end of the year?
WHAT IS THE NUMBER OF ZEROS AT THE END OF THE PRODUCT OF THE NUMBERS FROM 1 TO 100
two bowls are taken, one contains water and another contains tea equal amount . One spoon of water from 1st is added to second bowl and mixed well, and a spoon of mixture is taken from second bowl and added to the 1st bowl. Which statement will hold good for the above?
Find the hypotenuse of a right angle isoceles triangle whose area is 50.
Ganesh and Shankar travel abroad and take more luggage than the airlines allow. They have to pay extra money for it. They carry 52 kgs together and pay $60 and $100 respectively. Now, if the same luggage was carried by only Ganesh it would cost him $340. If the airlines charges only at one rate for extra luggage what is the maximum luggage that a person can carry without paying extra?
A coffee shop blends 2 kinds of coffee,putting in 2 parts of a 33p. a gm. grade to 1 part of a 24p. a gm.If the mixture is changed to 1 part of the 33p. a gm. to 2 parts of the less expensive grade,how much will the shop save in blending 100 gms.
In a class photograph, 5 girls are sitting in the front where as 20 boys are standing behind them. The corner two positions are reserved for the tallest boys of the class. What are the number of ways the students may be arranged?
The rectangle box with square base is open at the top. The maximum volume of the box made from 1200 m2 tin,in m3 is?
Seema's weight is 25% of Sunita's weight and 40% of Tanisha's weight. What percentage of Tanisha's weight is Sunita's weight?
Technical questions