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
Answers were Sorted based on User's Feedback
Answer / ajay
class A
{
public static void main(String args[])
{
int[] a1={1,2,3,4};
int[] a2=new int[9];
a2[0]=5; a2[1]=6; a2[2]=7; a2[3]=8; a2[4]=9;
for(int i=8;i>=4;i--)
a2[i]=a2[i-4];
for(int i=0;i<=3;i++)
a2[i]=a1[i];
for(int i=0;i<=8;i++)
System.out.println(a2[i]);
}
}
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / 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 |
the plane question was asked.it took off from 7 degree 53' 6.1'' and landed at 8 degree 6' 43.5''.it takes 12 hours to travel between these points.then what will be local time at destination ?
Number Series 18,20,22,20,28,20,?
16 Answers IBM, KD, TCS,
Use Venn diagrams to answer each of the following questions. You must show your Venn diagram for each problem. 1. A survey of 80 sophomores at a certain western college showed the following: 36 take English ,32 take history 32 take political science 16 take history and English 16 take political science and history ,14 take political science and English 6 take all three How many students: a) take English and neither of the other two? ____________ b) Take none of the three courses? ____________ c) take history, but neither of the other two? ____________ d) take political science and history but not English? ____________ e) do not take political science?
13 Answers Accenture, JPMorgan Chase, Syntel,
There are 4 numbers as 5,8,2,1 Form 4, four digit numbers as A, B and find the sum?
(165)2-(164)2=
A room is 30 X 12 X 12. a spider is ont the middle of the samller wall, 1 feet from the top, and a fly is ont he middle of the opposite wall 1 feet from the bottom. what is the min distance reqd for the spider to crawl to the fly.
in a certain group there are two families red and brown;search for mahindra satyam for this paragraph
One clock ringes 7 O'clock in 7 sec.In how many seconds it will ring 10 O'clock.
A circular dartboard of radius 1 foot is at a distance of 20 feet from you. You throw a dart at it and it hits the dartboard at some point Q in the circle. What is the probability that Q is closer to the center of the circle than the periphery? 0.75 1 0.5 0.25 Solution: 0.25 can someone plz explain how this answer is calculated?????
What is degree of a Relation?
How many bridges over yamuna river in Delhi?
what sort of questions may be asked