least remaining time program related to internet browsing

Discussion in 'C' started by ankit9555, Oct 28, 2009.

  1. ankit9555

    ankit9555 New Member

    Joined:
    Oct 28, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    You Have an Internet browsing center.
    only 1 machine is working.
    In order to control your customers allow them to use that machine one by on for a given time slot.The person who has minimum balance browsing time is allowed to use the machine first and once the time slot or his browsing time is over than that person has to wait till ever one has their turn.
    All the user are now allowed in the minimum browsing time left order.You have to return the schedule of browsing in the order in which the each person started to use the machine.
    you can use
    int browsingtime[],int n,int timeslots
    browsingtime is an array of time customer wants to browse,
    n represent size of browsingtime array,timeslot is integer value of time for each customer to access the machine
    EXAMPLE
    INPUT:
    browsingtime{10,7,3,4,11}
    timeslot=5
    n=5
    Output:
    Schedule Array as
    Schedule{3,4,5,5,5,2,5,5,1}
    size of schedule array=9
     
  2. ankit9555

    ankit9555 New Member

    Joined:
    Oct 28, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    please reply me quckly

    implement this logic in c++ program
    it

    [FONT=&quot]struct IntArray getSchedule(int browsingTime[], int noOfPersons, int timeSlot)[/FONT][FONT=&quot][/FONT]
    ·[FONT=&quot] [/FONT][FONT=&quot]Where browsingTime is an array of time the customer wants to browse, [/FONT]
    [FONT=&quot]noOfPersons represents the size of the browsingtime array and[/FONT]
    [FONT=&quot] timeSlot is integer value of Time for each customer to access the machine.[/FONT]
    ·[FONT=&quot] [/FONT][FONT=&quot]The Function returns structure IntArray which contains the integer array of [/FONT]
    [FONT=&quot]schedule (the order in which each person uses the machine) and the[/FONT]
    [FONT=&quot] size of the array.[/FONT]
     
  3. ankit9555

    ankit9555 New Member

    Joined:
    Oct 28, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    if anyone knows it please reply me as fast as possible
    implement this logic in a c++ program


    the program should contain this function
    [FONT=&quot]struct IntArray getSchedule(int browsingTime[], int noOfPersons, int timeSlot)[/FONT][FONT=&quot][/FONT]
    ·[FONT=&quot] [/FONT][FONT=&quot]Where browsingTime is an array of time the customer wants to browse, noOfPersons represents the size of the browsingtime array and
    [/FONT]

    [FONT=&quot]timeSlot is integer value of Time for each customer to access the machine.[/FONT]
    ·[FONT=&quot] [/FONT][FONT=&quot]The Function returns structure IntArray which contains the integer array of schedule (the order in which each person uses the machine) and the size of the array.[/FONT]
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Replying to your own post makes the post look "answered" and you are really better off leaving it at "0 replies" - we go through the forum looking for those.

    Also this is close to duplicate posting which is a banning offence. But thanks for not posting duplicate threads.

    Anyway, onto the subject. It looks quite easy, although there is a contradiction between the project outline and the example given: after having a go you have to wait until everyone has had a turn, but the example output shows 3,4,5,5..., i.e. 5 has two consecutive goes without waiting for 1-4, so this should be resolved with the "customer" (presumably the teacher, and this is not unrealistic because customers can often give conflicting requirements for a project in the real world). From the data given I would expect Schedule[] to start {3,4,2,1,5...} (assuming we're counting from 1, instead of from 0. Don't forget that if browsingtime[]={10,7,3,4,11}, then browsingtime[1]=7, not 10).

    How far have you got with the project and where are you stuck?

    Have you determined a suitable algorithm for the program? If not I would expect it to go along the lines of:
    1 find the user with the lowest non-zero value in browsingtime[] where the "had a go" flag has not been set (see 4)
    2 add that user to the end of Schedule[]
    3 deduct the actual browsed time from the user's entry in browsingtime[]
    4 set a flag to indicate this user has had a go and must now wait for everyone else
    5 (if all flags are set, everyone has had a go so reset them all)
    6 if there are any non-zero values left in browsingtime[] go back to 1
     
  5. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Also you don't automatically need to quote everything that you're replying to. This is a forum, not a newsgroup, and messages remain in the posted order. Quoting is required in newsgroups because messages can appear out of order and it can get very confusing; that is not the case in forums.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice