1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
xxTIMURxx [149]
3 years ago
12

Finish and test the following two functions append and merge in the skeleton file:

Computers and Technology
1 answer:
avanturin [10]3 years ago
4 0

Answer:

Explanation:

#include <iostream>

using namespace std;

int* append(int*,int,int*,int);

int* merge(int*,int,int*,int);

void print(int*,int);

int main()

{ int a[] = {11,33,55,77,99};

int b[] = {22,44,66,88};

print(a,5);

print(b,4);

int* c = append(a,5,b,4); // c points to the appended array=

print(c,9);

int* d = merge(a,5,b,4);

print(d,9);

}

void print(int* a, int n)

{ cout << "{" << a[0];

for (int i=1; i<n; i++)

cout << "," << a[i];

cout << "}\n";

}

int* append(int* a, int m, int* b, int n)

{

int * p= (int *)malloc(sizeof(int)*(m+n));

int i,index=0;

for(i=0;i<m;i++)

p[index++]=a[i];

for(i=0;i<n;i++)

p[index++]=b[i];

return p;

}

int* merge(int* a, int m, int* b, int n)

{

int i, j, k;

j = k = 0;

int *mergeRes = (int *)malloc(sizeof(int)*(m+n));

for (i = 0; i < m + n;) {

if (j < m && k < n) {

if (a[j] < b[k]) {

mergeRes[i] = a[j];

j++;

}

else {

mergeRes[i] = b[k];

k++;

}

i++;

}

// copying remaining elements from the b

else if (j == m) {

for (; i < m + n;) {

mergeRes[i] = b[k];

k++;

i++;

}

}

// copying remaining elements from the a

else {

for (; i < m + n;) {

mergeRes[i] = a[j];

j++;

i++;

}

}

}

return mergeRes;

}

You might be interested in
Using an API means that games take a performance hit, but are able to render more CPU intensive graphics.
Sergio [31]
Yes that is correct. Was there a specific question you wanted answered...
7 0
3 years ago
Read 2 more answers
Grade Co... ▶ Da'yana Stover - Aerospace Engineering.pdf
SVEN [57.7K]
The answer is Space shuttle.
8 0
1 year ago
Read 2 more answers
How does it transform your ways of socializing
frez [133]

How to transform your ways of socializing:

Know Yourself. The first and foremost reason why many people fail in effective socializing is the fact that they don’t know themselves well.

Be yourself. Another reason of failing to socialize or failing to make that “first impression” is that we try to mimic others.

Body Language. The way you walk, stand, talk, eat and sit… Each and every gesture and posture of yours speaks volumes about you.

Your attire. I had a client who had severe social anxiety. It was aggravated when her mother forced her to wear stuff that was too body revealing.

etc.

This was written from a biography about someones experience.

_____________________________

<em>Brainliest </em>would be greatly appreciated.

I found this!

______________________________

<em><u>#SpreadTheLove</u></em>

<em><u>#SaveTheTrees</u></em>

4 0
3 years ago
Is a floating point number smaller or larger than an integer?
Kaylis [27]
Floating point is basically binary scientific notation. So if you have a four byte float and a four byte integer, the float will have a greater range than the int. The float will also have slight anomalies. Play around with values like 0.3.
4 0
3 years ago
Functions of operating systems​
Jobisdone [24]

Answer:

The functions of operating system are:

Explanation:

It protects the user to create,copy,delete,move& rename files & folders.

It protects the stored information from unauthorized users & denies them access to data.

It manages the storage and retrieval of data from disks.

It manages the input to and output form of computer system.

7 0
3 years ago
Other questions:
  • Your desktop, internet explorer, and the media player can be started from this area on most computers
    9·1 answer
  • A prime number is an integer that is divisible only by 1 and by itself. Write a program that: 1. Takes a number as an input. 2.
    5·1 answer
  • A) How can jitter be reduced on a user’s PC if there is jitter in incoming packets?
    10·1 answer
  • Your windows system is used by several people, so you want increase security by requiring users to create passwords that are at
    9·1 answer
  • Accenture is helping a large retailer transform their online sales and services. The Data Analyst audits the client’s customer j
    12·1 answer
  • Write a program that plays the popular scissor-rockpaper game. (A scissor can cut a paper, a rock can knock a scissor, and a pap
    12·1 answer
  • What is problem scoping
    14·1 answer
  • Rita used information from a blog that someone else wrote. What should she do?
    7·1 answer
  • Please NEED HELP ASAP WILL MARK BRAINLIEST ONLY #8
    8·1 answer
  • According to the amendment, the federal government has only those powers specified by the Constitution. These powers include the
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!