Ask your own question, for FREE!
Computer Science 9 Online
OpenStudy (bahrom7893):

Need some help with C++.. I know you're not supposed to post your assignments here, but I don't want you to write the program. I'm just trying to understand the assignment.

OpenStudy (bahrom7893):

OpenStudy (bahrom7893):

OpenStudy (bahrom7893):

So far what I got from this is: A random person requests to buy a certain number of lots (100 shares), at a certain price per share. So, the total price would be: price per stock * (# of lots)/100

OpenStudy (bahrom7893):

and i didn't follow anything else.. Is all the info supposed to go into some vector? Can someone give me a few pointers?

OpenStudy (bahrom7893):

@estudier

OpenStudy (bahrom7893):

same here.. i have no darn clue what the heck the prof wants.. I'll prolly go talk to him on monday...

OpenStudy (bahrom7893):

yea, he mixed up the account numbers.

OpenStudy (bahrom7893):

i think it is.. im just not following what the program shld be doing.. And he's like use a vector, when he didn't even explain those. Not a big deal, i can read up on them, but still..

OpenStudy (anonymous):

I'm not sure about the Vector part either (something like a linked list? *shrug*), but here's what I understood from the sample run: The 'bid' commands are from the buyers in the format 'bid account_number number_of_lots bid_price_per_lot'. Initially the offer price is 25, and the first two bids don't have an offer greater than or equal to this. The third bid, however, is at 27 per lot, so it's executed immediately. The next command 'offer', changes the offer price per lot, in the format 'offer new_price'. So after 'offer 24', we have the price set at 24. However from the earlier two bids, one of them has an offer that meets this price, so that is executed. Then 'offer 25' doesn't cause any more executions because none of the pending or current transactions match. And that's how it goes. The only thing left is what your professor meant by 'vector'.

OpenStudy (anonymous):

Your professor is referring to an std::vector (see: http://en.cppreference.com/w/cpp/container/vector), a C++ standard library container. It is more flexible to use than an array and grows dynamically. You don't NEED to use an std::vector, but it provides functionality for the list of sales orders.

OpenStudy (anonymous):

@oldrin.bataku : So it is basically like a linked list, yeah? I'm not very well-versed with C++.

OpenStudy (anonymous):

No, a linked list is a different structure... though both can be used to implement a list. An std::vector generally stores an array that is reallocated when necessary to resize... the reason it can't be a typical linked list is because of the constraints the C++ standard places on the complexity of its operations. For example, random access in a linked list (std::slist, std::list) is O(n), while in an std::vector it is required to be O(1) (like an array).

OpenStudy (anonymous):

Oh, okay. I just read more on it now. Can see the difference. :) Thanks!

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!