CariDotMy

 Forgot password?
 Register

ADVERTISEMENT

View: 2469|Reply: 7

Sesiapa yg bole buatkan masalah programming ni tak?

[Copy link]
Post time 17-3-2007 07:32 PM | Show all posts |Read mode
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
Reply

Use magic Report


ADVERTISEMENT


Post time 17-3-2007 11:48 PM | Show all posts
mcm soalan assignment je...
Reply

Use magic Report

Post time 18-3-2007 01:06 AM | Show all posts
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.
Reply

Use magic Report

Post time 18-3-2007 11:31 AM | Show all posts
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:

  1. begin

  2.    initialize queue

  3.    get input
  4.    while input != 999
  5.    do
  6.       push input into queue
  7.       get input
  8.    end do (while input != 999)

  9.    initialize total_waiting_time = 0
  10.    initialize num_of_cars = 0
  11.    initialize average_waiting_time = 0
  12.    initialize temp

  13.    while queue is not empty
  14.    do
  15.       pop item from queue into temp
  16.       add temp to total_waiting_time
  17.       increment num_of_cars
  18.    end do (while queue is not empty)

  19.    average_waiting_time = total_waiting_time / num_of_cars
  20.    output average_waiting_time

  21. 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 ]
Reply

Use magic Report

Post time 18-3-2007 11:20 PM | Show all posts
hm... tak terjawap...
Reply

Use magic Report

Post time 20-3-2007 03:17 PM | Show all posts
Buat pakai C++ ??  makkk... Dah try tok guru Google?...
Reply

Use magic Report

Follow Us
surebelasah This user has been deleted
Post time 20-3-2007 05:01 PM | Show all posts
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..
Reply

Use magic Report

Post time 26-3-2007 08:46 PM | Show all posts
ini soklan cam subject data structure jer.. kekekkek tp nak ingatnya.. adoii dah lama la.. cuma ko tanya kawan2 ko kat U..
Reply

Use magic Report


ADVERTISEMENT


You have to log in before you can reply Login | Register

Points Rules

 

ADVERTISEMENT



 

ADVERTISEMENT


 


ADVERTISEMENT
Follow Us

ADVERTISEMENT


Mobile|Archiver|Mobile*default|About Us|CariDotMy

29-12-2024 01:43 PM GMT+8 , Processed in 0.491491 second(s), 22 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

Quick Reply To Top Return to the list