-
Notifications
You must be signed in to change notification settings - Fork 0
/
Q3.c
42 lines (35 loc) · 761 Bytes
/
Q3.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include<stdio.h>
void solveCase()
{
int a_num,b_num;
scanf("%d%d",&a_num,&b_num);
int a[a_num],b[b_num];
for(int i=0;i<a_num;i++)
scanf("%d",(a+i));
for(int i=0;i<b_num;i++)
scanf("%d",(b+i));
int index_a=0,index_b=0;
while(index_a<a_num && index_b<b_num)
{
printf("%d ",(a[index_a]>b[index_b])?a[index_a++]:b[index_b++]);
}
if(index_a>=a_num)
{
while(index_b<b_num)
printf("%d ", b[index_b++]);
}
else
{
while(index_a<a_num)
printf("%d ", a[index_a++]);
}
printf("\n");
}
int main()
{
int testCases;
scanf("%d",&testCases);
for(int i=1;i<=testCases;i++)
solveCase();
return 0;
}