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
leonid [27]
3 years ago
6

Write a program that reads a list of integers, and outputs those integers in reverse. The input begins with an integer indicatin

g the number of integers that follow. For coding simplicity, follow each output integer by a comma, including the last one.Ex: If the input is:5 2 4 6 8 10the output is:10,8,6,4,2,To achieve the above, first read the integers into a vector. Then output the vector in reverse.
Computers and Technology
1 answer:
Sergeu [11.5K]3 years ago
7 0

Answer:

The program in C++ is as follows:

#include <iostream>

#include <vector>

using namespace std;

int main(){

   vector<int> intVect;

   int n;

   cin>>n;

int intInp;

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

 cin >> intInp;

 intVect.push_back(intInp); }

for (int i = n-1; i >=0; i--) {  cout << intVect[i] << " "; }

 return 0;

}

Explanation:

This declares the vector

   vector<int> intVect;

This declares n as integer; which represents the number of inputs

   int n;

This gets input for n

   cin>>n;

This declares intInp as integer; it is used to get input to the vector

int intInp;

This iterates from 0 to n-1

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

This gets each input

 cin >> intInp;

This passes the input to the vector

 intVect.push_back(intInp); }

This iterates from n - 1 to 0; i.e. in reverse and printe the vector elements in reverse

for (int i = n-1; i >=0; i--) {  cout << intVect[i] << " "; }

You might be interested in
In order to implement the classic DoS flood attack, the attacker must generate a sufficiently large volume of packets to exceed
gavmur [86]

Answer:

131 packets

Explanation:

Given

W (link ) =0.5 M bits,  and Ping packets ( P ) = 500bytes

To flood a target organization that has a bandwidth of W bits using a packet Mbits, you will require a W / P packet

P ( required ) = 500  * 8 = 4000 bits

therefore the W /P packet is calculated as

= 0.5 M bits / 4000 bits

given that :  1 M bits =  1,048,576 bits

0.5 M bits / 4000 bits=  131.07  

hence approximately 131 packets/ sec is required to flood the target organization

4 0
3 years ago
Tạo thủ tục có tên _Pro04 để trả về số lượng tổng thời gian tham gia dự án Y của nhân viên có mã số X, với X là tham số đầu vào,
kompoz [17]

Answer:

nigro

Explanation:

6 0
3 years ago
Why does virtual reality rely on slightly different views for each eye?
GaryK [48]

Answer:

So, you can have a whole view, if you cover your right eye, you can't really see anything to your right just towards your left.

Explanation:

4 0
2 years ago
Mario kart is mercedes lol
anyanavicka [17]

Answer:

facts xD

Explanation:

6 0
3 years ago
Read 2 more answers
Name an analog quantity other than temperature and sound
liq [111]
I know that this might be wrong but is it light?
6 0
4 years ago
Other questions:
  • The buses that connect peripheral (typically input and output) devices to the motherboard are often called expansion buses. ____
    5·1 answer
  • A(n) __________ is the unit of file I/O accessed by an application program as a single unit. A(n) __________ is the unit of stor
    5·1 answer
  • On a piano, each key has a frequency, and each subsequent key (black or white) is a known amount higher. Ex: The A key above mid
    14·1 answer
  • 30 POINTS!!!
    9·2 answers
  • Shawn thought that the screen of the block-based program he was using was
    15·1 answer
  • The four general functions of any application program are: data storage, data access logic, application logic and presentation l
    11·1 answer
  • A city planner is using simulation software to study crowd flow out of a large arena after an event has ended. The arena is loca
    15·1 answer
  • The US government appropriates less than one million dollars in funding each year to STEM education programs. True False
    7·2 answers
  • Can someone compress this ipv6 address? 558c:0000:0000:d367:7c8e:1216:0000:66be
    9·1 answer
  • Does anyone know how to by pass this pls help?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!