Ask your own question, for FREE!
Computer Science 20 Online
OpenStudy (walters):

can someone explain how can i do this program pls using c++

OpenStudy (walters):

The bank would obviously like to make the most favourable such statement it can (i.e., find the period for which the average daily profit is the highest). However, it will only consider periods of at least a M days, since the customers will be suspicious if they indicate the profit over too short a period to be meaningful. Example Suppose that the bank made the following amounts for the customer over a number of days: R15, −R10, R10, R11, R10, R2, R10, R9, R11, R1; and that it wants to tell the customers about a period of at least 4 days. Then it can announce that from the 3rd to the 9th day (inclusive), it made an average of R9 a day. Input The first line of input contains an integer T, the number of test cases. T test cases follow. The first line of each test case contains two integers, N and M, separated by a space. The next N lines each contain an integer Pi, the profit (or loss, if negative) that the bank made on day i. Days are numbered from 1 to N. Sample input 1 10 4 20 -50 10 11 10 2 10 9 11 1

OpenStudy (walters):

@dpaInc pls help

OpenStudy (walters):

@agent0smith hepl!

OpenStudy (agent0smith):

Sorry man, I don't think I've ever used C++

OpenStudy (anonymous):

Where exactly are you stuck? Can you already read in the input data?

OpenStudy (walters):

i understand it ,but the coding part i don't know how can i doit

OpenStudy (walters):

@slotema

OpenStudy (anonymous):

The best way is to subdivide the code into parts and work on it one step at a time. In your program you're going to need to: 1) Read the input data and store it in an array/vector 2) Loop through the array and find the largest consecutive sum 3) Display the results Now the big question: how to write code for those parts? The best way IMHO is by reading some online tutorials or a good book on C++ programming.

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!