Question: Integer dataSize is read from input. Then, dataSize pairs of strings and integers are read and stored into string vector inventoryList and integer vector numberList,
Integer dataSize is read from input. Then, dataSize pairs of strings and integers are read and stored into string vector inventoryList and integer vector numberList, respectively. Lastly, string inventoryAsked is read from input. Complete the following tasks:
Initialize sumNumber with
Use a loop to find the sum of the elements in numberList where the corresponding element in inventoryList is equal to inventoryAsked. For each element in inventoryList that is equal to inventoryAsked, output "Index followed by the element's index. End with a newline.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
