c++ - Insert multiple elements in array - time count function -


I am working on an exercise on C ++ which demands a service queue to be emulated and it is a To do with the round, one dimension array. That is why it is demanded that when a customer comes to queue his name, the number of his card and the time of arrival comes in the queue.

So my first question is how can I enter all these elements in an array of elements? (I do not know that it is called the cell of the array or position, English is not my origin) Every customer has to keep only one situation and I must include all of them information in one situation I already have the conditions I know how an element can be incorporated or removed from a round qi, I do not know how to do many of them.

The second asks how much time a client is waiting for in the queue to see how many people are waiting for it before (although it is not very accurate).

For the first question: can you create a class or structure that represents the collection of data , And put the entire structure in your container?

(Edit: Customer is now a class, a constructor; an example of urgency added) You want to clean it a bit, but something like this:

  class customer {Private: std :: string m_name; Int m_card_number; Int m_arrival_time; Public: Customer (): m_card_number (0), m_arrival_time (0) {} // may require a default ctor client (constant std :: string name, int card_number, int_arrival time): m_name (name), m_card_number ( Card_number), m_arrival_time (time of arrival) {}}; Std :: duplication & lt; Customers & gt; Service_queue; // or your container customer C = client (name, card_name, current_time); Service_queue.push_back (c); For the second question   

; If you do not have to continue the time, and only need to work with the difference, then use a solution. Once you take your time difference (in ticks) and you need to change in seconds , Do not forget to divide by just CLOCKS_PER_SECOND.

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -