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
lana [24]
3 years ago
11

Read integers from input and store each integer into a vector until -1 is read. Do not store -1 into the vector. Then, output al

l values in the vector (except the last value) with the last value in the vector subtracted from each value. Output each value on a new line. Ex: If the input is -46 66 76 9 -1, the output is:
-55
57
67
Computers and Technology
1 answer:
weqwewe [10]3 years ago
6 0

Answer:

The program in C++ is as follows:

#include <iostream>

#include <vector>

using namespace std;

int main(){

vector<int> nums;

int num;

cin>>num;

while(num != -1){

 nums.push_back(num);

 cin>>num; }  

for (auto i = nums.begin(); i != nums.end(); ++i){

    cout << *i <<endl; }

return 0;

}

Explanation:

This declares the vector

vector<int> nums;

This declares an integer variable for each input

int num;

This gets the first input

cin>>num;

This loop is repeated until user enters -1

while(num != -1){

Saves user input into the vector

 nums.push_back(num);

Get another input from the user

 cin>>num; }

The following iteration print the vector elements

<em> for (auto i = nums.begin(); i != nums.end(); ++i){ </em>

<em>     cout << *i <<endl; } </em>

You might be interested in
Whats the flow in this code, and whats the risk that its creating and what can i do to fix it? (c language)
Advocard [28]

Answer:

The risk is a buffer overflow.

Explanation:

Whatever the user passes as a command line argument, will be copied into the buffer. If the user passes more than 499 characters, the end of the buffer will be overwritten.

To solve it, compare the string length of argv[1] to 500 before copying, or even better, start using the new strcpy_s( ) function.

6 0
3 years ago
Robots can obtain data from the environment, store the data as knowledge, and modify their behavior
TiliK225 [7]
True robots that have integrated ML can store data in specialized arrays which can be processed by the algorithms to give the output as their behaviour.
5 0
3 years ago
Heather is troubleshooting a computer at her worksite. She has interviewed the computer’s user and is currently trying to reprod
Aleksandr [31]

Answer:

D. Identify the problem.

Explanation:

There are six steps or stages in computer system troubleshooting. They are,

1. Identify the problem: In the stage of troubleshooting, the user is interviewed to get a description of the problem. Reproducing the problem is essential to confirm the described problem of the system before moving to the next stage.

2. Establish a theory of probable cause: when the problem is identified, a list of the possible cause of the problem is made.

3. Test the theory to determine a cause: each items on the list of possible cause of the problem is tested to confirm its actual cause.

4. Resolve the problem.

5. Verify full system functionality

6. Document the findings, actions and outcomes.

8 0
4 years ago
Given a matrix input_matrix, return a Numpy array that consists of every entry of A that has: an even row index in the range [0,
ipn [44]

Answer:

range [0, 7) an odd column index in the range [3, 8) This can be accomplished in a single line.

def PROBLEM3 (input_matrix):

# YOUR CODE GOES HERE

return output_matrix

# DO NOThern bus under

6 0
3 years ago
A debate about city schools are more better than village schools​
Vladimir [108]
No it is not because village school is the traditional education
6 0
3 years ago
Other questions:
  • What is a Software Quality Assurance Audit?
    12·1 answer
  • What is the first step that you should undertake when performing a visual analysis of a work of art?
    6·2 answers
  • Write a C# program named InchesToCentimeters that declares a named constant that holds the number of centimeters in an inch: 2.5
    14·1 answer
  • Below is the prototype for a function that takes two pointers to integer variables as its parameters. The purpose of the functio
    14·1 answer
  • Suppose Host A sends two TCP segments back to back to Host B over a TCP connection. The first segment has sequence number 90; th
    8·2 answers
  • Answer is B because portrait is define that they take only photographs of people and like to communicate with people they are we
    10·1 answer
  • The challenge of preparing for ____________________ is in ensuring that employees do not feel that they are being prepared for t
    7·1 answer
  • Plz help
    8·1 answer
  • For the following 4-bit operation, assuming these register are ONLY 4-bits in size, which status flags are on after performing t
    14·1 answer
  • Which is the most recent version of microsoft windows?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!