subject

g Reversing an array is a common task. One approach copies to a second array in reverse, then copies the second array back to the first. However, to save space, reversing an array without using a second array is sometimes preferable. Write a function that reads in an integer representing the length of the array. Then read in and reverse the given array, without using a second array. If the original array's values are 2 5 9 7, the array after reversing is 7 9 5 2. Write a method to reverse the input array and call the method in the main. Note: The first item in the input is the length of the input array. The rest of the items in the input are the elements stored inside of the input array. Hints: Use this approach: Swap the first and last elements, then swap the second and second-to-last elements, etc. Stop when you reach the middle; else, you'll reverse the vector twice, ending with the original order. Think about the case when the number of elements is even, and when odd. Make sure your code handles both cases.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 07:00
You need a quick answer from a coworker. the most effective way to reach your coworker is through a. cloud server b. instant message c. teleconference d. telepresence
Answers: 1
question
Computers and Technology, 23.06.2019 07:30
Write a program that inserts the digits of an integer into an array in originalorderfollowed by reverse order. first, promptthe user to enter a positive integer(> 0). determine the number of digits of the integer. create a dynamically allocated integer arrayof a size twice the number of digits.now insert the digits in original order which will occupy half of the array. then, insert the digits in reverse order.finally, output thedigits in thearray.use at least two functions to organize your program.
Answers: 3
question
Computers and Technology, 23.06.2019 20:00
What software programs are used to to create professional publication? a.) graphics programs b.) word processors c.) page layout programs d.) spreadsheet programs
Answers: 2
question
Computers and Technology, 24.06.2019 16:50
Develop the program incrementally: a) start by reading and displaying each line of the input file to make sure you are reading the data set correctly. b) use the split string method to extract information from each line into a list. print the list to prove that this step is working correctly. d) convert the exam scores to type int and calculate the student’s average. display those items to prove this step is working correctly. e) create a tuple containing the six items for each student (name, exam scores, exam mean). display the tuples to prove this step is working correctly. (optionally, you may want to have the exam scores in a list so your tuple is (name, scores_list, f) append each tuple to a list. display the list to prove this step is working correctly. g) use the sort list method to re-order the tuples in the list. display the list to prove this step is working correctly. h) use a for statement to display the contents of the list as a table (with appropriate formatting). i) use a for statement to calculate the average of all scores on exam #1, then display the results. note that you could have calculated this average within the first loop, but we are explicitly requiring you to do this calculation by looping though your list of tuples. j) add the logic to calculate the average of all scores on exam #2, then display the results.
Answers: 2
You know the right answer?
g Reversing an array is a common task. One approach copies to a second array in reverse, then copies...
Questions
question
Law, 14.02.2020 02:40
question
Mathematics, 14.02.2020 02:40
question
Mathematics, 14.02.2020 02:40
Questions on the website: 13722360