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
Montano1993 [528]
2 years ago
9

Write a function named swapFrontBack that takes as input a vector of integers. The function should swap the first element in the

vector with the last element in the vector. The function should check if the vector is empty to prevent errors. Test your function with vectors of different length and with varying front and back numbers.
Computers and Technology
1 answer:
kondaur [170]2 years ago
4 0

Answer:

#include <iostream>

#include <vector>

using namespace std;

void swapFrontBack(vector<int>& nums) {

if(nums.size() < 2) {

return;

}

swap(nums[0], nums[nums.size()-1]);

}

void printit(vector<int>& arr) {

for(int i = 0; i < arr.size(); i++) {

cout << arr[i] << " ";

}

cout << endl;

}

int main() {

vector<int> num1;

swapFrontBack(num1);

printit(num1);

num1.push_back(1);

swapFrontBack(num1);

printit(num1);

num1.push_back(2);

swapFrontBack(num1);

printit(num1);

vector<int> num2(10, 1);

num2[9] = 2;

swapFrontBack(num2);

printit(num2);

return 0;

}

Explanation:

You might be interested in
Durante 10s, la velocidad de rotación y el momento de giro de las ruedas de un coche eléctrico son 100 rpm y 1405,92 Nm, respect
Akimi4 [234]

Answer:

c

Explanation:

hope this helps

6 0
3 years ago
If directory server a trusts directory server b, directory server b trusts directory server c, and directory server a trusts dir
topjm [15]
This is a transitive trust which is a two-way correlation routinely made among parent and child domains in a microsoft active directory forest and when a new domain is produced, it bonds resources with its parent domain by evasion in which allowing an valid user to access resources in together the child and parent.
4 0
3 years ago
____________ occurs when a provider does not support data export or when a provider's service is unavailable through others.
elixir [45]

Answer:

The correct answer to the following question will be Vendor Lock-In.

Explanation:

Vendor Lock-In: It is also known as Customer Lock-In. The Vendor Lock-In makes the costumer depends on services and products on the vendor. The costumers are not able to use another vendor without changing costs as it creates barriers.

Some ways to avoid Vendor Lock-In, these are as follows:

  • Design your application portable.
  • Keep watching vendor contracts.
  • Arrange both entry and exit with your vendor.

8 0
3 years ago
Please help ASAP!
makkiz [27]
B. training is the correct answer
8 0
2 years ago
Which is the default scripting language in most browsers? A. ASP B. JavaScript C. PHP D. XML
vodomira [7]

Answer:

Javascript

Explanation:

Ive learned about it and its the most known one.

4 0
3 years ago
Other questions:
  • The code selection above is taken from the Color Sleuth activity you just completed. This selection would count as an abstractio
    12·1 answer
  • List 3 ways that you can use excel and the features it includes and explain why a spreadsheet is the best choice for this task.
    5·1 answer
  • Write a statement that declares a prototype for a function powerTo, which has two parameters. The first is a double and the seco
    14·1 answer
  • Megan has written the following rough draft for her assignment. Choose the correct way to complete each sentence. Sarah is creat
    13·1 answer
  • Which option is used to apply formatting to multiple objects on a single slide while still maintaining the ability to manage the
    14·2 answers
  • Nate wants to copy the style of his contact address to the normal template. Complete the paragraph to describe how he can access
    6·1 answer
  • What device provides ports to allow a laptop to easily connect to a full-sized monitor, keyboard, ac power adapter, and other pe
    11·1 answer
  • How to automatically ccleaner smartphone?
    10·1 answer
  • It was field day for the upper grades at Rock Creek School,
    7·1 answer
  • What are two reasons to tie cables up and out of the way inside a computer case?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!