C++ and leave comments explaining. Thank you
You are given two STL lists X and P where n P is already in sorted order. Write a valid C++ function
printPositions(X,P) that prints the elements in X specified by P. For example, if P = 0, 3, 7, 8, the elements in positions 0 (head of the list), 3, 7, and 8 in
X are printed. You may use only the public STL container operations. Also specify the running time of your algorithm using Big-Oh notation.
Hint: You may wish to use iterators while keeping track of the position of items being iterated through.
In: Computer Science
Write a program that given a number entered through a cell, say if it is positive or not positive.
programming language is VB8
In: Computer Science
MATLAB: Write a function called max_number that takes an at most two-dimensional matrix A as its sole input. The function returns the largest element of A. You are not allowed to use the built-in max function.
In: Computer Science
in BASIC language, i need to make function smallMiles(size) display the smallest number in the MilesDriven array . here is my code so far:
size =1
Dim Monthname$(size)
Dim MilesDriven(size)
do
print "Enter your choice from this menu."
print "Enter 'P' to enter miles and month,OR"
print "Enter 'S' to search for month. OR,"
print "Enter 'M to search month with smallest miles. OR,"
print "Enter 'L' to search for month with largest miles. OR,"
print "Enter 'E' to exit."
input choice$
select case (choice$)
case "P","p"
res= collectData(size)
case "S","s"
res = search(size)
case "M","m"
res = smallMiles(size)
case "L","l"
res = largeMiles(size)
case "E","e"
print "Have a nice day.Goodbye."
case else
print "Invalid choice, please try again"
print
end select
loop until (choice$ = "E" or choice$ = "e" )
function collectData(size)
for position= 0 to size
print "Enter miles."
input MilesDriven(position)
print "Enter month."
input Monthname$(position)
next
end function
function search(size)
print "Enter month."
input month$
for position = 0 to size
if(month$ = Monthname$(position))then
print "The month is: ";Monthname$(position)
print "The number of miles driven is: ";MilesDriven(position)
exit for
end if
next
end function
function smallMiles(size)
print "Enter month."
input month$
for position = 0 to size
smallest = MilesDriven(position)
if (month$ = Monthname$(position))then
if (MilesDriven(position) < smallest )then
smallest = MilesDriven(position)
end if
print "The month with smallest miles driven is:
";Monthname$(position)
print "The smallest miles driven is: ";smallest
exit for
end if
next
end function
In: Computer Science
c++ program to calculate the sum of the rows and the columns in a multidimensional array
In: Computer Science
Write a program that reads a student's code and grades from all four tests of any matter; and calculate and print the final grade for the subject, along with the student code. Taking into account that: The value of the first is 15% The value of the second is 25% The value of the third is 30% The value of the fourth is 40%
Programming language is VB8
In: Computer Science
Which command is used to hold open a very short or zero-length file?
In: Computer Science
USB memory devices are displayed in Linux as which of the following?
In: Computer Science
You has been requested to design and develop a food ordering system in C++ language based on following requirements:
The system shall allow the user to place an order for the food(s), view the food details, modify or delete the details of the food if necessary. Your program should be menu driven, giving the user various choices. You shall design the system by demonstrating the full understanding of object-oriented and use of list/link-list concept.
For every food order, the following information will be stored: Order ID (Auto assigned, unique ID), Food Code, flavor (example: Strawberry, chocolate), weight (Kg), Unit Price, Qty and customer information who order this cake. The customer information consists of customer ID, name, address and contact number. The order ID shall be automatically assigned with a unique ID when new order is added. The system shall display additional information that is amount (unit price * qty) when viewing the order details.
In: Computer Science
Write a method to return the surface area of a right rectangular prism given the dimensions Example: surface_area(3, 5, 7) returns 142. Java Program (Using Method)
In: Computer Science
Write a Python function that will ask the user for an integer X bigger than 20 and return a list "ls" of 10 distinct random integers taken between the interval 0, to X. None of the 10 elements of "ls" should be repeated.
In: Computer Science
Show algebraically the payoff of a butterfly spread using calls in the following cases:
– ST < K1
– K1 < ST < K2
– K2 < ST < K3
– ST > K3
Assume K2 is the average of K1 and K3: K2 = .5*(K1 + K3) or 2K2 =
K1 + K3 (i.e., the butterfly trade is symmetric). You can use this
relationship to simplify the final expressions quite a
bit.
In: Computer Science
Write a Python function that will return the index of an element in a list.1- The function will receive a list of at least 5 numbers as a single argument when the function is called. 2. The function will ask the user to input a number and will find and return the index of that number in the list.3. If the number is not an element of the list, the function returns the string "unknown."
In: Computer Science
1. Yes or No? Recall the heuristics from the 8-puzzle problem: h1 is the number of out of place tiles, and h2 is the Manhattan distance. Is a combined heuristic (h1 + h2)/2 also admissible? Provide a justification.
2. In a fully observable, turn-taking, zero-sum game between two perfectly rational players, it does not help the first player to know what move the second player will make.
In: Computer Science
Write a Python program that will ask the user to input a word, will return the first letter of the input word, and ask the user to put another word, and so on, in the form of a loop. If the user chooses to stop, he or she should input the integer "0" for the loop to stop.
In: Computer Science