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
Find the hypotaneous of a right angle isoceles triangle whose area is 50.
A can work three times as B can work. If A takes 60 days less than B to complete the same task, calculate the number of days when both A and B start working together on the same day.
it has 20 mixutre conatins mil and water in the ratio 3:5,replace 4 litres of mixture with 4 litres of water what is the final ratio of milk and water.
A person travels 6km towards west, then travels 5km towards north ,then finally travels 6km towards west. Where is he with respect to his starting position?
After spending 2/3 of his salary on rent and food items and 1/4th of the remaining on transportation, Rajesh has 6000 with him. How much did he pay on transportation?
A,B,C,D,E are some numbers.if AB * CD = EEE and CD - A =CC THEN what is AB * D =? IN SAME CODE .
The sum of the digits of a two digit number is 8. When 18 is added to the number, the digits are reversed. the number?
If TAFJHH is coded as RBEKGI then RBDJK can be coded as ---------
A boy multiplied a number with 10 and got 100,instead of dividing it . If he divided it what would be the answer?
2 persons start from a pt. and go in opposite directions. After going 3 km they turn left and walk 4 km . how far r they now?
Find the number WXYZ divisible by 36? i) Let the digits be5, 4,3,6 -not in that order ii) Sum of last two digits is 9 iii) Sum of middle two digits is 7->If one is sufficient then ans as A || if two is sufficient then ans as B || if all are necessary then ans as C || if nothing is needed then
The price of Machine D equals the sum of the prices of machine A, B and C whose price are in the ratio 2:3:4 respectively. If weights of A, B, C and D varies as square of its individual price and difference of weight of D and A, B and C together is 9880 kg. Then what is the weight of D?
The average of 4 consecutive even numbers is 27. What is the largest number?
If r = 5, n=3 and if first pole has 2 flags, third pole has 1 flag, how many ways can the flags be arranged?
A contractor employed 200 men to complete a strip of highway in 200 days. After 150 days he found that only 3/5th of the strip is complete. How many additional men should be employed to complete the work on time?