Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   least remaining time program related to internet browsing (http://www.go4expert.com/forums/remaining-time-program-related-internet-t19907/)

ankit9555 28Oct2009 10:04

least remaining time program related to internet browsing
 
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

ankit9555 28Oct2009 12:19

Re: least remaining time program related to internet browsing
 
Quote:

Originally Posted by ankit9555 (Post 59472)
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

please reply me quckly

implement this logic in c++ program
it

struct IntArray getSchedule(int browsingTime[], int noOfPersons, int timeSlot)
Where browsingTime is an array of time the customer wants to browse,
noOfPersons represents the size of the browsingtime array and
timeSlot is integer value of Time for each customer to access the machine.
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.

ankit9555 28Oct2009 12:22

Re: least remaining time program related to internet browsing
 
Quote:

Originally Posted by ankit9555 (Post 59472)
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

if anyone knows it please reply me as fast as possible
implement this logic in a c++ program


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

timeSlot is integer value of Time for each customer to access the machine.
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.

xpi0t0s 28Oct2009 14:06

Re: least remaining time program related to internet browsing
 
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

xpi0t0s 28Oct2009 14:11

Re: least remaining time program related to internet browsing
 
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.


All times are GMT +5.5. The time now is 03:18.