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.

Answers

Answer 1

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:


Related Questions

10101 base 2 - 110+2​

Answers

Answer:

-87

Explanation:

(10101 base 2) = 21

21 - 110 +2 = -87

HELP! Write a program that generates 6 random numbers between 0 and 30, prints the numbers as shown, calculates the sum and the average of these numbers, and prints them

Answers

The program that generates 6 random numbers between 0 and 30 and makes mathematical computations is:

import random

import statistics

a = random.random()

b = random.random()

c = random.random()

d = random.random()

e = random.random()

f = random.random()

print("Generated Numbers:")

print(a, b, c, d, e, f)

seq = (a, b, c, d, e, f)

mean = statistics.mean(seq)

median = statistics.median(seq)

mode = statistics.mode(seq)

print("Mean =", mean)

print("Median =", median)

print("Mode =", mode)

Read more about programming here:

https://brainly.com/question/23275071

#SPJ1

(a) What are computer scanning device
(b)Name the type of scanner used:

Answers

Answer
Answer A):- A scanner is a device that captures images from photographic prints, posters, magazine pages and similar sources for computer editing and display. Scanners work by converting the image on the document into digital information that can be stored on a computer through optical character recognition (OCR).

Answer b):-The information will include; cost, and how its used The four common scanner types are: Flatbed, Sheet-fed, Handheld, and Drum scanners.
Hope it Helps!

(n) ____ operator requires a single operand either before or after the operator. unary single binary

Answers

A unary operator requires a single operand either before or after the operator.

Who is a  unary operator?

This is known to be a person or  an operator that is often known to use or operate only on a single operand so as to return a new value.

Note that A unary operator requires a single operand either before or after the operator.

Learn more about   unary operator from

https://brainly.com/question/13814474

#SPJ1

A license may limit the use of a software application to a specific device. Group of answer choices True False

Answers

Answer:

true

Explanation:

As part of your regular system maintenance, you install the latest operating system updates on your Windows 10 computer. After several days, you notice that the system locks up and reboots from time to time. You suspect that a recent update is causing the problem. How can you quickly restore the computer to its state before the updates

Answers

Answer is restore the system using a restore point.
Explained: System Restore lets you roll your system settings back to a specific date when everything was working properly.

Which component of CIA triad ensures that the connectivity and performance are maintained at the highest possible level

Answers

The component of CIA triad ensures that the connectivity and performance are maintained at the highest possible level is Availability.

What is Availability in CIA triad?

Availability is known to be the information that needs to be consistently and one that is said to be readily accessible in times of need by authorized parties.

Note that for a thing to be available, it means that that thing can be accessible at any time and any day. it is an attribute that is not very common and as such, it brings about high performance and easy connectivity.

Hence, in the above case, The component of CIA triad ensures that the connectivity and performance are maintained at the highest possible level is Availability.

Learn more about CIA triad from

https://brainly.com/question/17269063

#SPJ1

You are the computer specialist in a small business. Your company server is named FS1 and has an IP address of 10.0.0.2. The hardware in your company server started to experience intermittent failures, so you transferred the shares on the server to a spare server and took the main server offline. The spare server has an IP address of 10.0.0.3. You edit the existing A record for FS1 on your company's DNS server and redirect the hostname to the spare server's IP address of 10.0.0.3. Afterward, most users are able to access the shares on the spare server by hostname, but several users cannot. Instead, they see an error message indicating that the FS1 server could not be found. Enter the command you can run from the command prompt on these workstations that will allow them to access the shares on FS1 without performing a full restart.

Answers

The command for the above case is:

ipconfig /flushdns

Deletes local DNS name cache

What is  system command?

This is known to be a form of a user's instruction that is often given by the computer and it is one that requires for action to be done by the computer's executive program.

Note that The command for the above case is:

ipconfig /flushdns

Deletes local DNS name cache

Learn more about  IP address from

https://brainly.com/question/24930846

#SPJ1

Ready to attempt the final challenge? Supply the 3 passwords you received via the first 3 challenges to proceed! Password from challenge #1 (all lowercase): Password from challenge #2 (all lowercase): Password from challenge #3 (all lowercase):

Answers

Using the knowledge in computational language in python it is possible to write a code that through a list manages to organize the largest and smallest numbers in order.

Writting the code in python:

# finding largest in the list

list_max = challenge3[0]

for i in range(len(challenge3)) :

   if challenge3[i] > list_max :

       list_max = challenge3[i]        

print("largest in the list = ", list_max)

# number of times largest occurs in list

max_count = 0

for i in range(len(challenge3)) :

   if challenge3[i] == list_max :

       max_count += 1        

print("number of times largest occurs in list = ", max_count)

# finding second largest in the list

list_sec_max = challenge3[0]

for i in range(len(challenge3)) :

   if challenge3[i] > list_sec_max and challenge3[i] < list_max :

       list_sec_max = challenge3[i]        

print("second largest in the list = ", list_sec_max)

# number of times second largest occurs in list

sec_max_count = 0

for i in range(len(challenge3)) :

   if challenge3[i] == list_sec_max :

       sec_max_count += 1        

print("number of times second largest occurs in list = ", sec_max_count)

# location of first occurence of largest in the list

first_index = -1

for i in range(len(challenge3)) :

   if challenge3[i] == list_max :

       first_index = i

       break        

print("location of first occurence of largest in the list = ", first_index)

# location of first occurence of largest in the list

last_index = -1

for i in range(len(challenge3) - 1, -1, -1) :

   if challenge3[i] == list_sec_max :

       last_index = i

       break        

print("location of first occurence of largest in the list = ", last_index)

See more about python at brainly.com/question/13437928

#SPJ1

The constructor for Object supports methods that are used to retrieve and define properties for any object. True False

Answers

The constructor for Object supports methods that are used to retrieve and define properties for any object is a True statement.

What is the constructor of an object?

The Object constructor is known to be one that forms an object wrapper for any kind of given value.

When the value is null or undefined , it will form and return an empty object and as such, The constructor for Object supports methods that are used to retrieve and define properties for any object is a True statement.

Learn more about Object supports  from

https://brainly.in/question/34445581

#SPJ1

If you want to stop a loop before it goes through all of its iterations, the break statement may be used. Group of answer choices True False

Answers

Answer:

Answer is true

Explanation:

When evaluating a website's content, whether or not the information is up to date is considered part of the ________ element.

Answers

The currency element constitutes information whether the information of the website is current or up to date.

Website

A website is a term used to describe unique publicly accessible web pages that are identified by a domain name. Information on websites is typically updated by website owners, hence, some websites may not be updated frequently when compared to others. Thus, the currency element is an element users take into consideration when evaluating a website's content, whether or not the information is up to date.

You can learn more about the currency element here https://brainly.in/question/48673521

#SPJ1

Select the correct answer.
What does firewall software do?
A.
It improves network connectivity.
B.
It monitors network traffic to block malicious content.
C.
It adds some new features to the operating system.
D.
It installs viruses in the system.

Answers

Answer:

B

because it is an antivirus

Which feature of cryptography is used to prove a user's identity and prevent an individual from fraudulently reneging on an action?

Answers

A feature of cryptography which is used to prove an end user's identity and prevent an individual from fraudulently reneging on an action is nonrepudiation.

What is nonrepudiation?

Nonrepudiation can be defined as an assurance that the sender of a message is given a proof of delivery and the recipient of this message is also provided with a proof of the sender’s identity, so none of them can deny having processed this message.

This ultimately implies that, nonrepudiation is a security service which has a feature of cryptography and it can be used to prove an end user's identity and prevent an individual from fraudulently reneging on an action

Read more on nonrepudiation here: brainly.com/question/14631388

#SPJ1

Which web-authoring software enables users to create sophisticated web pages without knowing any html code?.

Answers

Answer: One of the best software

Explanation: Dreamweaver!

Chris is responding to a security incident that compromised one of his organization's web servers. He believes that the attackers defaced one or more pages on the website. What cybersecurity objective did this attack violate

Answers

The cybersecurity objective that the above attack violate is known as Integrity.

What is Cybersecurity aims?

Their objectives is majorly to protect any computers system, networks, and other kinds of software programs from any type of cyber attacks.

Note that The cybersecurity objective that the above attack violate is known as Integrity as they are not the kind of people that keep to their words.

Learn more about cybersecurity from

https://brainly.com/question/12010892

#SPJ1

1. A teacher asked a student to capture and print out a one-slide presentation using MSWord,       showing everything on the screen.
i)       What keys or combination of keys can be used to carry out this operation ?
ii)     Describe the procedures to be followed by the student in carrying out this operation?
iii)  Describe the procedure to be followed by the student in carrying out this assignment using the keyboard.
b) A system Analyst was hired to set up a computer laboratory for Gan di Gan International      School,
    i.) Mention three hardware devices the analyst would need to set up the laboratory
   ii) List two database applications likely to be recommended by the analyst
  iii) State five Word Processing packages likely to be installed

Answers

The keyboard combinations that can be used to capture and print out a one-slide presentation using MSWord, showing everything on the screen is Function key + PrtScr

What is a Key Combination?

This refers to the procedure that is used to combine two or more keys on the keyboard to execute a task.

Hence, we can see that the procedure that can be used to carry out the operation is:

Enter the screen you want to capture and printPress the Function key, followed by the PrtScr. Please note this can vary slightly, depending on the keyboard.

The hardware devices that would be needed to be set up by the system analyst at a computer laboratory are:

System UnitLaptops/MonitorPower adaptersEthernet cables, etc

The database applications that can be recommended by the system analyst are:

MySQL, SQL Server

The five word processing packages that are likely to be installed are:

G00..gle DocsMsWordMSOfficeDropbox PaperCorel WordPerfect

Read more about word processing here:

https://brainly.com/question/985406

#SPJ1

Assume your organization has 200 computers. You could configure a tool to run every Saturday night. It would query each of the systems to determine their configuration and verify compliance. When the scans are complete, the tool would provide a report listing all systems that are out of compliance, including specific issues. What type of tool is being described

Answers

The tool that would provide a report listing all systems that are out of compliance, including specific issues is Security Compliance Manager.

What are compliance tools?

The Security Compliance Manager is known to be a form of downloadable tool that one can use as it helps a person to plan, ascribe, operate, and manage a person's security baselines for Windows client and other forms of server operating systems.

Note that in the case above, The tool that would provide a report listing all systems that are out of compliance, including specific issues is Security Compliance Manager.

Learn more about Security Compliance Manager from

https://brainly.com/question/24338783

#SPJ1

_____ are standard settings that control how the screen is set up and how a document looks when you first start typing

Answers

The standard settings that control how the screen of a computer is set up and how a document looks when you first start typing is called default settings.

What is a word processing software?

A word processing software can be defined as a type of software that is designed and developed so as to enable its end users type, format and save text-based documents such as:

In Computer technology, the standard settings that control how the screen of a computer is set up and how a document looks when you first start typing on a word processing software is called default settings.

Read more on word processing here: brainly.com/question/24043728

#SPJ1

Despite how well you might take care of your computer, problems can always arise. when troubleshooting problems you encounter, at what point should you engage a professional for assistance? why? at what point might you consider purchasing a new computer?

Answers

If troubleshooting problems is the one you encounter, the best thing to do is for one to get a professional to help one to see if the problem with the hardware  is one that is within the computer chassis.

What is troubleshooting?

Troubleshooting is known to be a form of systematic method that is often used in problem-solving that is known to help one to see and also correct issues that are linked with complex machines, electronics, computers and software systems.

Hence, If troubleshooting problems is the one you encounter, the best thing to do is for one to get a professional to help one to see if the problem with the hardware  is one that is within the computer chassis.

Learn more about troubleshooting from

https://brainly.com/question/9572941

#SPJ1

Write a method reverse that takes an array as an argument and returns a new array with the elements in reversed order. Do not modify the array.

Answers

Answer:

public class ArrayUtils

{

//function to reverse the elements in given array

public static void reverse(String words[])

{

//find the length of the array

int n = words.length;

//iterate over the array up to the half

for(int i = 0;i < (int)(n/2);i++)

{

//swap the first element with last element and second element with second last element and so on.

String temp;

temp = words[i];

words[i] = words[n - i -1];

words[n - i - 1] = temp;

}

}

public static void main(String args[])

{

//create and array

String words[] = {"Apple", "Grapes", "Oranges", "Mangoes"};

//print the contents of the array

for(int i = 0;i < words.length;i++)

{

System.out.println(words[i]);

}

//call the function to reverse th array

reverse(words);

//print the contents after reversing

System.out.println("After reversing............");

for(int i = 0;i < words.length;i++)

{

System.out.println(words[i]);

}

}

Explanation:

Think about how you view your emails—either the email service you use yourself or an email service you would choose to use. Describe that email service and then explain whether you use POP3 or IMAP to access your email. How do you know it’s POP3 as opposed to IMAP?

Answers

Answer:

and POP3, followed in later years. POP3 is still the current version of the protocol, though this is often shortened to just POP. While POP4 has been proposed, it's been dormant for a long time.

IMAP, or Internet Message Access Protocol, was designed in 1986. Instead of simply retrieving emails, it was created to allow remote access to emails stored on a remote server. The current version is IMAP4, though most interfaces don't include the number.

The primary difference is that POP downloads emails from the server for permanent local storage, while IMAP leaves them on the server while caching (temporarily storing) emails locally. In this way, IMAP is effectively a form of cloud storage.

Think about how you view your emails is either the email service you use yourself or an email service you would choose to use POP3, followed in later years.

What is POP3?

POP3, followed in later years as the POP3 is still the current version of the protocol, though this is often shortened to just POP. While POP4 has been proposed, it's been dormant for a long time.

IMAP, or Internet Message Access Protocol, was designed in 1986. Instead of simply retrieving emails, it was created to allow remote access to emails stored on a remote server. The current version is IMAP4, though most interfaces don't include the number.

The primary difference is that POP downloads emails from the server for permanent local storage, while IMAP leaves them on the server while caching (temporarily storing) emails locally. In this way, IMAP is effectively a form of cloud storage.

Therefore, Think about how you view your emails is either the email service you use yourself or an email service you would choose to use POP3, followed in later years.

Learn more about emails on:

https://brainly.com/question/14666241

#SPJ2

In 25 words or fewer, explain why businesses use social media to digitally market their products.

Answers

Due to the accessibility of social media platforms, businesses have the opportunity to follow their potential customers. Social media marketers need to know more about their target market's needs, wants, and interests in order to develop a more effective marketing plan to draw in these potential customers.

What is social media?

Social media is a term used to describe online communication. Social media systems enable users to have discussions, exchange information, and create content for the internet.

Users utilize social media networks, sometimes referred to as digital marketing, as a platform to create social networks and share information in order to develop a company's brand, boost sales, and enhance website traffic.

Hence, the significance of the social media is aforementioned.

Learn more about on social media, here:

https://brainly.com/question/18958181

#SPJ1

why over the course of time have more programming language been developed​

Answers

technology and being able to communicate?

What was one effect of better printing methods during the Ming Dynasty? Updated trade routes A new merchant class Increased literacy rates More codes and laws

Answers

The one effect of better printing methods during the Ming Dynasty For millennia its mastery made China the only withinside the international capable of produce copies of texts in splendid numbers and so construct the biggest repository of books.

What have been 3 consequences of the printing revolution?

Printed books have become extra conveniently to be had due to the fact they have been less difficult to supply and inexpensive to make. More humans have been capable of learn how to study due to the fact they may get books to study.

As in Europe centuries later, the advent of printing in China dramatically diminished the fee of books, for that reason assisting the unfold of literacy. Inexpensive books additionally gave a lift to the improvement of drama and different kinds of famous tradition. Freed from time-ingesting hand copying, the unfold of tradition and know-how accelerated, ushering international civilization onto a brand new stage.

Read more about the Ming Dynasty:

https://brainly.com/question/8111024

#SPJ1

Answer:

c

Explanation:

Toni is reviewing the status of his organization's defenses against a breach of their file server. He believes that a compromise of the file server could reveal information that would prevent the company from continuing to do business. What term best describes the risk that Tony is considering

Answers

Due to the fact that Toni is reviewing the status of his organization's defenses against a breach of their file server, the best describes the risk that Tony is considering is Strategic risk.

What is Strategic risk?

This is known to be a form of internal and external events that often render it hard, or lets say impossible, for a firm to achieve their aims and strategic goals.

Note that, Due to the fact that Toni is reviewing the status of his organization's defenses against a breach of their file server, the best describes the risk that Tony is considering is Strategic risk.

Learn more about file server from

https://brainly.com/question/17062016

#SPJ1

1. Explain what peer to peer networking is.
2. Describe at least one pro and one con of peer to peer networking.
3. Describe at least one pro and one con of network printer connections.
4. Describe at least one pro and one con of local printer connections.
5. Choose and explain, step by step, one method of backing up student files either manually or using a cloud service.

Answers

Peer-to-peer networking

Peer-to-peer networking is a term used to describe a system of communication that allows a group of computers to exchange information in a permissionless way.

One pro of -peer-to-peer networking is that it decentralizes how information is transferred and secured since files are stored on just a single device.

On the other hand, a con of peer-to-peer networking is the possible exposure to harmful data such as malware. been transferred from another computer.

You can learn more about peer-to-peer networks from a similar question here https://brainly.com/question/1932654

#SPJ1

Write a program that lists all ways people can line up for a photo (all permutations of a list of strings). The program will read a list of one word names (until -1), and use a recursive method to create and output all possible orderings of those names, one ordering per line.
When the input is:
Julia Lucas Mia -1
then the output is (must match the below ordering):
Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Lucas Mia Julia Mia Julia Lucas Mia Lucas Julia ------File: main.cpp------
#include
#include
#include
using namespace std;
// TODO: Write method to create and output all permutations of the list of names.
void AllPermutations(const vector &permList, const vector &nameList) {
}
int main(int argc, char* argv[]) {
vector nameList;
vector permList;
string name;
// TODO: Read in a list of names; stop when -1 is read. Then call recursive method.
return 0;
}

Answers

The code that lists all the possible permutations until -1 that corrects the problem in your code is:

#include <algorithm>

#include <iostream>

#include <vector>

int main() {

   std::vector<std::string> names{

       "Julia", "Lucas", "Mia"

   };

   // sort to make sure we start with the combinaion first in lexicographical order.

   std::sort(names.begin(), names.end());

   do {

       // print what we've got:

       for(auto& n : names) std::cout << n << ' ';

       std::cout << '\n';

       // get the next permutation (or quit):

   } while(std::next_permutation(names.begin(), names.end()));

}

Read more about permutations here:

https://brainly.com/question/1216161

#SPJ1

which Yandere Simulator update removed the box of matches?

Answers

Answer:

Fixed the glitchy physics of Yandere-chan’s latest hairstyle. Removed exploit that allowed players to keep a character stationary indefinitely by talking to a student about their Task and never dismissing the Task Window. Adjusted the pathfinding grid so that it should be less likely for a student’s path to the male locker room to be blocked.

Explanation:

Answer:

i couldnt find the exact year but heres a list of bug fixes n stuff if this helps

Explanation:

https://yandere-simulator.fandom.com/wiki/Update_History

Which type of input devices used in big hero 6 movie

Answers

The  Input Devices Used in Movie Big Hero are:

A joystick medical robot Armored exoskeleton Jet-boots.

What are input device?

This is known to be a is a piece of instrument that helps gives or provide data to any information processing system.

Note that the Input Devices Used in Movie Big Hero “6”  are  a medical robot made by by Tadashi Hamada., Armored exoskeleton and others.

Learn more about input device from

https://brainly.com/question/24455519

#SPJ1

Other Questions
What are meristematic tissues? Mention its different types, its location in plant body Explain why mr. gatz would want to bury gatsby "down east" instead of in minnesota where he grew up. Can somebody help me with this question its timed..Ill appreciate it thank you!Choose the correct answer What is the total finance charge for a $4,250 loan at 13.25% interest compounded monthly for 24 months? a. $25.47 b. $202.55 c. $611.20 d. $4,861.20 please select the best answer from the choices provided a b c d please help me on this question. im not the best at geometry Please help me....trying to get my HS diploma, i did not graduate :(A ball is thrown in air and it's height, h(t) in feet, at any time, t in seconds, is represented by the equation h(t)=t2+7t. When is the ball higher than 10 feet off the ground?A. 2B. 5t2C. 2t5D. 5 Find an equation of the line passing through the given points. Use function notation to write the equation,(-4,9) and (2,-3) Alcohol can leave the body in three ways, they are: Why are diode logic gates not suitable for cascading operation? solve the equation cos (x/2) = cos x + 1. what are the solutions on the interval 0 x < 360? Which element should be included in the body paragraphs of a research essay?background informationsummary of main pointsengaging hooktopic sentence witch hazel is listed at 12 per galon, less 34.5%. what is the net cost of the amount needed in filling the prescription A fence is to be built to enclose a rectangular area of 200 square feet. The fence along three sides is to be made of material that costs 3 dollars per foot, and the material for the fourth side costs 12 dollars per foot. Find the dimensions of the enclosure that is most economical to construct. The graph below shows a company's profit f(x), in dollars, depending on the price of pens x, in dollars, sold by the company:Graph of quadratic function f of x having x intercepts at ordered pairs 0, 0 and 6, 0. The vertex is at 3, 120.Part A: What do the x-intercepts and maximum value of the graph represent? What are the intervals where the function is increasing and decreasing, and what do they represent about the sale and profit? (4 points)Part B: What is an approximate average rate of change of the graph from x = 3 to x = 5, and what does this rate represent? (3 points)Part C: Describe the constraints of the domain. (3 points) While driving, Carl notices that his odometer reads 25,952 miles, which happens to be a palindrome. He thought this was pretty rare, but 2.5 hours later, his odometer reads as 36,563 miles, anoher palindrome. What was Carl's average speed during those 2.5 hours Find the equation of the plane passing through the points A=(1,1,1), B=(1,4,5), C=(3,-2,0).Find the area of the triangle the 3 points from the first equation.Find the angle between the 2 vectors; (1) from A to B and (2) from C to B. teniendo en cuenta las caracteristicas de la literatura de terror que rasgos se encuentran en la obra "otra vuelta de tuerca"? find the area of a circle whose radius is 'x', unit. 100POINTS WHY NOT sally took money from her bank account to go out of town for an audition.she spot 54$ for a round trip ticket and 1/2 of the remaining money on her hotel bill.she spent $7.90 for food and arrived home with $15.10.How much money did Sally take from her bank account?? A uniform rod with a mass of m = 1.94 kg and a length of l = 2.10 m is attached to a horizontal surface with a hi=nge. The rod can rotate without friction. (See figure.)Initially the rod is held at rest at an angle of = 70.4 with respect to the horizontal surface. Then the rod is released.What is the angular speed of the rod, when it lands on the horizontal surface?What is the angular acceleration of the rod, just before it touches the horizontal surface?