Please write these problems in C++ format 24. a) Write a function named append t
ID: 3626517 • Letter: P
Question
Please write these problems in C++ format
24. a) Write a function named append that passes in 2 vectors of doubles. The function should append the 2nd vector to the end of the 1st vector. For example, if the first vector has the values, 2.1, 3.4, 4.5 and the second vector has the values, 1.0, 1.2, 2.3, 2.4 then when the function ends, the first vector should have the following values in this order, 2.1, 3.4, 4.5, 1.0, 1.2, 2.3, 2.4. The second vector should NOT be changed at all.
b) Write a main function that tests this function at least once. You may initialize each vector argument with any values you choose, but you must give them at least 3 values each.
25. Write a function named within that passes in a Circle object and 4 doubles representing the left and right x coordinates and top and bottom y coordinates of a rectangle. The function should return true if the entire Circle is within the rectangle or false if it is not. In other words, if any part of the Circle is touching or outside of the borders of the rectangle, the function should return false.
Explanation / Answer
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
void append(vector<double>& v,const vector<double>& v1)
{
for(int i=0; i<v1.size(); i++)
v.push_back(v1[i]);
}
int main()
{
double a[]={2.1, 3.4, 4.5 };
double b[] ={1.0, 1.2, 2.3, 2.4};
vector<double> v(a,a+3);
vector<double> v1(b,b+4);
append(v,v1);
for(int i=0; i<v.size(); i++)
cout<<v[i] << " " ;
return 0;
}