View: 2469|Reply: 7
|
Sesiapa yg bole buatkan masalah programming ni tak?
[Copy link]
|
|
kepada otai2 programming, boleh tak korang dptkan coding untuk masalah programming ni guna c++? :
Queues are employed in many simulations. For example in simulating traffic flow
at a car wash service. Assume there is one station in the car wash. Each car
takes exactly 10 minutes to get washed. At any time, there can be at most five
cars waiting in the queue to be washed (that means, the car wash can accept 6
cars at a time |
|
|
|
|
|
|
|
mcm soalan assignment je... |
|
|
|
|
|
|
|
itula pasal.
Dik, sekarang pasaran IT makin sengit. Adik cuba buat dulu, mana-mana stuck nanti abang-abang dan kakak-kakak yang tahu akan tolong. |
|
|
|
|
|
|
|
cuba baca your textbook.
queues are part of a data structure (other data structure include linked lists, stacks, tree, graphs etc)... queues are quite a simple implementation of a data structure, konsep dia macam kita beratur kat bank, First In First Out (FIFO)
so a typical data structure for a queue would consist of the following:
1. the queue itself
2. methods for:
- checking the size of the queue
- checking if the queue is empty
- checking if the queue is at its maximum size (kalau guna array)
- inserting an item into the queue (push)
- removing an item from the queue (pop)
so, kalau your problem, algorithm dia as follows:
- begin
- initialize queue
- get input
- while input != 999
- do
- push input into queue
- get input
- end do (while input != 999)
- initialize total_waiting_time = 0
- initialize num_of_cars = 0
- initialize average_waiting_time = 0
- initialize temp
- while queue is not empty
- do
- pop item from queue into temp
- add temp to total_waiting_time
- increment num_of_cars
- end do (while queue is not empty)
- average_waiting_time = total_waiting_time / num_of_cars
- output average_waiting_time
- end
Copy the Code
kalau tak faham, google aje: c++ queue
kalau lagi tak faham, PM saya. the pseudocode above should solve your problem already. tak kisah la nak coding C++ ke, Java ke, VB ke...
good luck.
[ Last edited by shahnazz at 18-3-2007 11:33 AM ] |
|
|
|
|
|
|
|
Buat pakai C++ ?? makkk... Dah try tok guru Google?... |
|
|
|
|
|
|
surebelasah This user has been deleted
|
Heh. Soalan nih ok lagi. Masa aku belajar dulu assignment dia macammana nak bg keretapi buat U-turn ngan post-fix calculator. Trick dia main ngan recursive jer.. |
|
|
|
|
|
|
|
ini soklan cam subject data structure jer.. kekekkek tp nak ingatnya.. adoii dah lama la.. cuma ko tanya kawan2 ko kat U.. |
|
|
|
|
|
|
| |
|