5.18 LAB: Output numbers in reverse Write a program that reads a list of integers, and outputs those integers in reverse. The input begins with an integer indicating 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 10 the output is: 10,8,6,4,2, To achieve the above, first read the integers into a vector. Then output the vector in reverse.

Answers

Answer 1

Answer:

In C++:

#include<iostream>

#include<vector>

using namespace std;

int main(){

   int len, num;

   vector<int> vect;

   cout<<"Length: ";

   cin>>len;  

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

       cin>>num;

   vect.push_back(num);}

   vector<int>::iterator iter;

   for (iter = vect.end() - 1; iter >= vect.begin(); iter--){

       cout << *iter << ", ";}    

}

Explanation:

This declares the length of vector and input number as integer

   int len, num;

This declares an integer vector

   vector<int> vect;

This prompts the user for length  

cout<<"Length: ";

This gets the input for length  

   cin>>len;  

The following iteration gets input into the vector

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

       cin>>num;

   vect.push_back(num);}

This declares an iterator for the vector

   vector<int>::iterator iter;

The following iterates from the end to the beginning and prints the vector in reverse

   for (iter = vect.end() - 1; iter >= vect.begin(); iter--){

       cout << *iter << ", ";}


Related Questions

the _ and _ services help us to keep in touch with our family and friends

Answers

Answer:

Internet and communication technology

You are going on vacation and want to take some work files. You need a storage device that is small enough to fit in your bag and preferably one that does not have plugs. Which device should you bring?


hard drive bus

flash drive

external hard drive

storage card

Answers

Answer:

Flash drive

Explanation:

25 POINTS PLATO
Drag the tiles to the boxes to form correct pairs.
Pat creates a table in a spreadsheet program, starting at cell A1 and ending at cell B4. Column A contains words, while column B contains the words’ meanings. Pat wants to look up the meaning of the word "paramount", which is present in cell A3. How should Pat write the LOOKUP function? Refer to the syntax of the function and match the arguments in the syntax to their values.

Syntax: LOOKUP(lookup value; search table; result table)

B1:B4
"paramount"
A1:A4

lookup value
search table
result table

Answers

Answer:

lookup value   =  "paramount"

Search table   =  A1:A4

Result table     =  B1;B4

Explanation:

lookup, what are we looking up.....:::///????Paramount

What is the beginning search table......A1;A4

Column B contains the words meanings.....this is the result we want:

So the Result table......B1:B4

LOOKUP("paramount"; B1:B4; A1:A4)  should Pat write the LOOKUP function.

What is a LOOKUP function?

Lookup functions entail accessing a cell, comparing its values to those in an adjacent row or column, and then extracting the relevant answers from the associated columns or rows of Excel.

The lookup value, the search table, and indeed the result table are the three inputs required by the LOOKUP function. The value you are searching for, in this case, "paramount," is the lookup value.

The table that contains the lookup value, throughout this example B1:B4, is known as the search table.

The table where the results of the lookup are stored is known as the result table, and in this example, A1:

Pat should use the columns which would have the cell value of B1, B4 as well as A1.

Learn more about the LOOKUP function, here:

https://brainly.com/question/29517410

#SPJ3

when working with smart which tab would provide the ability to change the shape or size of the smart art shapes

Answers

It doesn’t change shape

Answer:

B) Format

Explanation:

1, How can technology serve to promote or restrict human rights? [2 points]

Answers

Answer:

Examples of how technology can be used as a powerful tool for human rights are ever expanding. Newer technologies such as artificial intelligence, automation, and blockchain have the potential to make significant positive contributions to the promotion and protection of human rights.

Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: calcAverage: This method should accept five test scores as arguments and return the average of the scores. determineGrade: This method should accept a test score as an argument and return a letter grade for the score, based on the following grading scale:

Answers

Answer:

See comment for complete question

#include <iostream>

using namespace std;

double calc_Average(double sc1, double sc2, double sc3, double sc4, double sc5){

   return (sc1 + sc2 + sc3 + sc4 + sc5)/5;

}

char determine_Grade(double score){

   char grade;

   if(score >= 90 && score <=100){

       grade = 'A';}

   else if(score >= 80 && score <90){

       grade = 'B';}

   else if(score >= 70 && score <80){

       grade = 'C';}

   else if(score >= 60 && score <70){

       grade = 'D';}

   else if(score <60){

       grade = 'F';}

   return grade;

}

int main(){

   double sc1,sc2, sc3, sc4, sc5;

   cout<<"Enter 5 scores: ";

   cin>>sc1>>sc2>>sc3>>sc4>>sc5;

   cout<<"Score: "<<sc1<<" Grade: "<<determine_Grade(sc1)<<endl;

   cout<<"Score: "<<sc2<<" Grade: "<<determine_Grade(sc2)<<endl;

   cout<<"Score: "<<sc3<<" Grade: "<<determine_Grade(sc3)<<endl;

   cout<<"Score: "<<sc4<<" Grade: "<<determine_Grade(sc4)<<endl;

   cout<<"Score: "<<sc5<<" Grade: "<<determine_Grade(sc5)<<endl;

   double Ave = calc_Average(sc1,sc2,sc3,sc4,sc5);

   cout<<"Average: "<<Ave<<" Grade: "<<determine_Grade(Ave)<<endl;

   return 0;

}

Explanation:

The program was written in C++. Because of the length of the explanation, I've added the explanation as an attachment where I used comments to explain the lines of the code.


Output devices include:
A) Printers, and Monitors
B) CPU
C) System Unit
D) None of the above

Answers

Answer:

CPU IS TH ANSWER BECAUSE IT IS OUT

Was Nick Carson a good project manager? Why or why not?

Answers

Answer:

Nick Carson is not a good project manager because he did not focus on all aspects of the project. He also failed to provide accurate schedules and also detailed plans on the happenings of the project. He was performing other jobs leaving aside the work of project manager. Without concerning and understanding the problem of top management he delivered the project.

Explanation:

Write code to take two words from the user. The program should convert these to lower case, then compare them: printing a positive number if string1 appears after string2 alphabetically, a negative number if string1 appears before string2 alphabetically and zero if the two strings are identical. Make sure your program does not produce any additional numerical output other than this number or it may not be graded correctly.

Answers

Answer:

Use compareTo.

Explanation:

import java.util.Scanner;

public class U2_L3_Activity_Three{

 public static void main(String[] args){

   Scanner scan = new Scanner(System.in);

   System.out.println("Enter first word: ");

   String word1 = scan.nextLine();

   System.out.println("Enter second word: ");

   String word2 = scan.nextLine();

//I had to make the string all lowercase or all uppercase for when I did this

   word1 = word1.toLowerCase();

   word2 = word2.toLowerCase();

   System.out.println("Result: " + word1.compareTo(word2));

 }

}

Following are the program to converting string value into lowercase and compare with an input string value.

Program Explanation:

Import package.Defining a class Dat.Inside the class defining the main method, and in the method, two string variable "string1, string2" is declared.After input, the value a "toLowerCase" method is used that converts string value into lower case.  After converting value into the lower case a "compareTo" method is used that compares value and prints its value.

Program:

import java.util.*;//import package for input  

public class Dat //defining a Dat

{

public static void main(String[] ax)//main method

{

String string1 ,string2; //defining String variable

Scanner sc = new Scanner(System.in);//creating Scanner class object to input value

System.out.println("Enter values: ");//print message

string1= sc.next();//input value

string2= sc.next();//input value

string1= string1.toLowerCase();//convert string value into LowerCase  

string2 = string2.toLowerCase();//convert string value into LowerCase

System.out.println("Result: " + string1.compareTo(string2));//using compareTo method

}

}

Output:

Please find the attached file.

Learn more:

brainly.com/question/15706308

Are items a through e in the following list algorithm? If not, what qualities required of algorithms do they lack?
a. Add the first row of the following matrix to another row whose first column contains a nonzero entry. (Reminder: Columns run vertically; rows run horizontally.)
[1 2 0 4 0 3 2 4 2 3 10 22 12 4 3 4]
b. In order to show that there are as many prime numbers as there are natural numbers, match each prime number with a natural number in matching the first prime number with 1 (which is the first natural number) and the second prime number with 2, the third with 3, and so forth. If, in the end, it turns out that each prime number can be paired with each natural number, then it is shown that there are as many prime numbers as natural numbers.
c. Suppose you're given two vectors each with 20 elements and asked to perform the following operation. Take the first element of the first vector and multiply it by the first clement of the second vector. Do the same to the second elements, and so forth. Add all the individual products together to derive the dot product.
d. Lynne and Calvin are trying to decided who will take the dog for a walk. Lynne suggests that they flip a coin and pulls a quarter out of her pocket. Calvin does not trust Lynne and suspects that the quarter may be weighted (meaning that it might favor a particular outcome when tossed) and suggests the following procedure to fairly determine who will walk the dog.
1. Flip the quarter twice.
2. If the outcome is heads on the first flip and tails on the second, then I will walk the dog.
3. If the outcome is tails on the first flip, and heads on the second, then you will walk the dog.

Answers

Answer:

Following are the responses to the given points:

Explanation:

The following features must contain a well-specified algorithm:

Description [tex]\to[/tex] Exact measures described

Effective computation   [tex]\to[/tex]  contains steps that a computer may perform

finitude  [tex]\to[/tex]  It must finish algorithm.

In choice "a", there is little algorithm Because it does not stop, finiteness has already been incomplete. There is also no algorithm.

In choice "b", it needs productivity and computational burden. because it's not Enter whatever the end would be.

In choice "c", the algorithm is given the procedure. It fulfills all 3 algorithmic properties.

In choice "d", each algorithm is a defined process. Since it needs finitude.

Write the definition of the function inputArray that prompts the user to input 20 numbers and stores the numbers into alpha. Write the definition of the function double Array that initializes the elements of beta to two times the corresponding elements in alpha. Make sure that you prevent the function from modifying the elements of alpha. Write the definition of the function copy AlphaBeta that stores alpha into the first five rows of matrix and beta into the last five rows of matrix. Make sure that you prevent the function from modifying the elements of alpha and beta. Write the definition of the function printArray that prints any one-dimensional array of type int. Print 15 elements per line.

Answers

Answer:

In Java:

public static  int[] inputArray(){

   Scanner input = new Scanner(System.in);

   int[] alpha = new int[20];

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

       alpha[i] = input.nextInt();

   }

   return alpha;}

public static  int[] doubleArray(int [] alpha){

   int[] beta = new int[20];

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

       beta[i] = 2 * alpha[i];

   }

   return beta;

}

public static int[] copyAlphaBeta(int [] alpha, int [] beta){

   int [] AlphaBeta = new  int[10];

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

       AlphaBeta[i] = alpha[i];

   }

   int count = 5;

   for(int i = 15;i<20;i++){

       AlphaBeta[count] = beta[i];

       count++;

   }

   return AlphaBeta;

}

public static void printArray(int [] alpha){

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

       System.out.print(alpha[i]+" ");

       if((i+1)%15 == 0){

           System.out.println(" ");

       }

   }

}

Explanation:

The inputArray is defined here

public static  int[] inputArray(){

   Scanner input = new Scanner(System.in);

This declares alpha array of 20 elements

   int[] alpha = new int[20];

The following iteration gets input from the user into the array

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

       alpha[i] = input.nextInt();

   }

This returns the alpha array

   return alpha;}

The doubleArray is defined here. It takes the alpha array as its input parameter

public static  int[] doubleArray(int [] alpha){

This declares beta of 20 integers

   int[] beta = new int[20];

This populates beta by 2 * alpha[i]

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

       beta[i] = 2 * alpha[i];

   }

This returns the alpha array

   return beta;}

The copyAlphaBeta array is defines here

public static int[] copyAlphaBeta(int [] alpha, int [] beta){

This declares AlphaBeta as 10 elements

   int [] AlphaBeta = new  int[10];

This populates the first 5 elements of AlphaBeta with the first 5 of alpha

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

       AlphaBeta[i] = alpha[i];

   }

   int count = 5;

This populates the last 5 elements of AlphaBeta with the last 5 of beta

   for(int i = 15;i<20;i++){

       AlphaBeta[count] = beta[i];

       count++;

   }

This returns the AlphaBeta array

   return AlphaBeta;

}

The printArray is defined here. It takes the alpha array as its input parameter

public static void printArray(int [] alpha){

This iterates through alpha array

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

This prints each element of the array

       System.out.print(alpha[i]+" ");

A new line is started after the 15th element

       if((i+1)%15 == 0){

           System.out.println(" ");

       }

   }

}

See attachment for complete program which includes the main

Methods ii.) Define and implement a method that takes a string array as a parameter and returns the length of the shortest and the longest strings in the array i.) Write a method that take an integer array as a parameter and returns the sum of positive odd numbers and sum of positive even numbers. iii.) Implements the sequential search method that takes and array of integers and the item to be search as parameters and returns true if the item to be searched in the array, return false otherwise

Answers

Answer:

Explanation:

Well I am sorry I don't know the answer anyway.

3. Given the following total revenue functions, find the corresponding demand functions:

a) TR = 50Q-4Q²
b) TR = 10

Answers

a)TR=50Q4Q2 I hope.this helps

A) The demand function for the total revenue function TR = 50Q - 4Q² is;

P = 50 - 4Q

B) The demand function for  the total revenue function TR = 10 is; 10/Q

We are given total revenue functions as;

TR = 50Q - 4Q²

TR = 10

A) TR = 50Q - 4Q²

Formula for revenue function if Q represents the units demanded is;

TR = P × Q

Where P is the demand function

Thus;

50Q - 4Q² = PQ

Divide both sides by Q to get the demand function;

P = 50 - 4Q

B) TR = 10

Formula for revenue function if Q represents the units demanded is;

TR = P × Q

Where P is the demand function

Thus;

10 = P × Q

Divide both sides by Q to get the demand function;

P = 10/Q

Read more at;https://brainly.com/question/13701068

We are supposed to go to the concert tomorrow, but it has been raining for three days straight. I just know that we won’t be able to go.

7. What is the author’s tone? ​

Answers

Its the worried tone

Hope this helps!

There Will Come Soft Rains is a warning story about nuclear war and how, in the end, technology won't keep us safe. In response to the atomic bombings of Hiroshima and Nagasaki, Bradbury penned the tale.

What author’s worried tone indicate about rain?

Ray Bradbury wrote the classic science fiction short tale “There Will Come Soft Rains” in 1950. The narrative is narrated in a detached, emotionless tone, as though the events that are taking place are a normal part of everyday life.

The story's meaning can be found in the story's complete lack of human beings, not even corpses.

Soft rain rays will appear in the short story. Bradbury creates a disorganized, somewhat post-apocalyptic atmosphere. To better understand the zeitgeist of the world, he employs a variety of literary techniques.

Therefore, It's the worried tone author’s.

Learn more about author’s here:

https://brainly.com/question/1308695

#SPJ5

I need help Asap!!! So the question is "Compare and contrast Web page and Websites". ​

Answers

Answer:

A website is a mix of web pages while a web page is a single entity.

Explanation:

Other Questions
Scientists Believe that:A. The continents are shiftingB. The world was once one big massC. The center of the earth is made of iron and nickel D. All of the aboveE. None of the above living in the darkAccording to the author, what is the main obstacle to exploring the ocean depths? Explain why, citing evidence from the text.. A pair of shoes that normally sells for $74.88 goes on sale for 25% off. What is the sale price? What were some of the things that Europeans needed in order to begin to sail on the ocean and find an all water route to Asia? Students in a class were asked to name their favorite type of soup. The results are shown in the circle graph. How many times more students prefer tomato soup than prefer French onion soup? French onion=0.06% Tomato=33% parte de la carta de opinin en la que se presenta el autor y el motivo de la carta "You figure you can ride Ghost Wind, then get on. Just bring him back to the stable when you're finished so I can rub him down." I dismounted, leaving the stallion with Mitchell, and headed toward the barn. Now, I truly expected that Mitchell would come after me with Ghost Wind. After all, despite my invitation, I knew Mitchell couldn't ride Ghost Wind. As far as I knew, Mitchell had never ridden more than a mule and had no idea how to ride a thoroughbred tornado like Ghost Wind. But instead of Mitchell following me, the next thing I knew, I heard a triumphant cry, turned, and saw Mitchell atop the stallion dashing across the meadow. For a moment all I could do was stand and stare. But then, as the stallion bucked, left the meadow, and headed for the woods, I suddenly found my legs and my voice, and I began running and screaming after Mitchell and the stallion. "Pull back the reins!" I hollered as I ran. "Mitchell, the reins! Pull back hard!" The Land, Mildred D. Taylor Use the drop-down menus to answer the questions. Which type of conflict is Mitchell having in this passage? Is this a major or minor conflict in the overall novel? Consider the system of equations.8x+2y=8 y= 4x+4 The system has blank solutions.SELECT CHOICEno,infinitely many,one. Which sign makes the statement true? 1 plz help!!!! ill mark brainliest!! Bernadette Wolowitz and her puppy are entering a beauty contest together.Connecting SubjectsConnecting ObjectsConnecting VerbsConnecting Complete Thoughtswhich on is it!? Adigital option is one in which the payoff depends in a discontinuous way on the asset price. The simplest example is the cash-or-nothing option, in which the payoff to the holder at maturity T is X1{ST>K} where X is some prespecified cash sum. Suppose that an asset price evolves according to the binomial model in which, at each step, the asset price moves from its current value Sn to one of Snu and Snd. As usual, if T denotes the length of each time step, d < erT < u. Find the time zero price of the above option. You may leave your answer as a sum. 11 ounces of tomato soup has 70 calories. How many calories are in 22ounces of soup? * Question 4 20 pts The measure of an interior angle of a regular polygon is 120. Find the number of sides. How does the sign for "Child" differ from the sign for "Children"?OA.the sign for "Children" involves making the sign for "Child" with both hands at the same time instead of one handthe sign for "Child" uses the Chandshape but the sign for "Children" does notthe sign for "Child" is always signed with the right hand, while the sign for "Children" always uses the left handthe sign for "Children" involves movement, while the sign for "Child" does notOD.Yes After substituting, what is the first step when evaluating (4y+9)/7 when Y = 8: *:*: *:*: *:*: *:*A. Add 4 and 9. B. Multiply 8 by 4. C. Divide 9 by 7. D. Divide 4 by 7.: *:*: *:*: *:*: *:* Find the area of the shape shown below Find the length of the indicatedside of the similar figure.x = [?]Enter the number that belongs in the green box. Find the value of x and the measure of the angle labeled 3x.A. x= 14; angle measure is 30B. x = 10; angle measure is 42".C. x = 14; angle measure is 42"D. x = 10; angle measure is 30 which population is most likely to increase as a result? A. deerB. mouseC. owlD. Hawk