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
in a railway station, there are tow trains going. One in the harbour line and one in the main line, each having a frequency of 10 minutes. the main line service starts at 5 o'clock. the harbour line starts at 5.02a.m. a man goes to the station every day to catch the first train. what is the probability of man catchinhg the first train
3/p=6, 3/q=15 ......find p-q
If 15 pens costs Rs.90..then what will be the cost of 22pens?
Complete the sequence A, E ,I ,M ,Q ,U , _ , _?
a, b, b, c, c, c, d, d, d, d, . . . . . . Find the 288th letter of this series?
There are 150 weights .Some are 1 kg weights and some are 2 kg weights. The sum of the weights is 260.is the number of 1kg weights?
a grandfather has 5 sons and daughters and grandchildren.they have to be arranged in a row such that the first 4 seats and last four seats are to be taken by grandchildren and the grandfather would not sit adjacent to any of the grandchildren.
Light glows for every 13 seconds . How many times did it glow between 1:57:58 and 3:20:47 am.
the matrix of a(7,9) was given.the address of the first byte of a(1,1)=1258.it takes 4 bytes to store the nuymber. then calculate the address of the last byte of a(5,8)
If 12 box containers require 18 feet of wall space, how many feet of wall space will 30 box containers require?
If the equation x2 - 3x + a = 0 has the roots (0,1) then value of a is ?
There are 19 red balls and one black ball . Ten balls are put in one jar and the remaining 10 are put in another jar. what is the possibility that the black is in the right jar.
15 Men take 21 days of 8 hrs. each to do a piece of work. How many days of 6 hrs. each would do if 21 women take. If 3 women do as much work of 2 men.
In 1978, a kg of paper was sold at Rs25/. If the paper rate increases at 1.5% more than the inflation rate which is 6.5% a year, then what will be the cost of a kg of paper after 2 years?
hi...i have got selected for United bank po interview.can anyboby suggest me how to prepare for interview.r there any books for po interview?i am asking because..this s my 1 st bank interview...pls send me interview material if u have any ..my mail id=pruthi_tarun@yahoo.co.in....thank u